Calibre regex guide: batch-rename ebooks with regular expressions

You just imported 300 books into Calibre and the titles look like John_Smith-The_Great_Novel_v2_FINAL (1).epub. Manually renaming each one would take an evening you’ll never get back. Calibre’s regex-powered bulk metadata search-and-replace handles this in 30 seconds — if you know the right patterns.

What regex can do in Calibre

Open Calibre, select your books, hit Edit metadata in bulk, then switch to the Search and replace tab. You get two modes:

  • Search mode: Character match — simple find-and-replace like a text editor. Works for straightforward cleanup like “replace all underscores with spaces.”
  • Search mode: Regular expression — this is where the magic happens. Pattern matching that can restructure your entire title format in one pass.

The three patterns that solve 90% of problems

1. Remove author names from titles

Many download sites prefix titles with the author, giving you “King, Stephen - The Shining” when you only want “The Shining.”

Search: ^[^-]+ - Replace: (leave empty) Explanation: ^[^-]+ means “everything from the start of the string until the first dash.” The - after it includes the separator. Deleting the match cleans the title.

2. Strip version numbers and “(FINAL)”

Search: \s*v\d+(\.\d+)*\s*|\(FINAL\)|\(updated\) Replace: (leave empty) Explanation: \s*v\d+ matches ” v2” or ” v3.1.4”. The | means “or” — this single pattern removes version numbers, “(FINAL)”, and “(updated)” all at once.

3. Restructure “LastName, FirstName” to “FirstName LastName”

For author fields that come in backwards.

Search field: authors Search: (.+),\s*(.+) Replace: \2 \1 Explanation: (.+) captures text into groups. \1 is the first group (last name), \2 is the second (first name). This flips them: “King, Stephen” becomes “Stephen King”.

Building a multi-step cleaning recipe

For a truly chaotic library, combine these into a recipe you run in sequence:

  1. Title cleanup — strip author names, version numbers, site prefixes
  2. Author normalization — flip last-first formats, merge duplicates
  3. Series detection — use regex to auto-detect series patterns like “Book 1 of X”
  4. Tag generation — derive tags from existing metadata (e.g., “pdf” in title → tag “PDF Source”)

Save your most-used regex patterns in a text file. Calibre doesn’t have a built-in regex library, but keeping them handy means you’re 30 seconds away from a clean library every time you import a batch.

When regex isn’t enough

If your titles are truly chaotic — random strings, missing metadata, no consistent pattern — switch to Calibre’s Download metadata feature instead. It queries online databases (Amazon, Google Books, ISBNdb) to pull clean titles and covers automatically. Regex is your precision scalpel; metadata download is your bulldozer.

Advertisement
Ad