buy batch renamer

Buy From Us for $29.95

30 Day No-Hassle Money Back Guarantee, all purchases include discounted upgrades and we offer site and forever licenses.

Upgrade

Purchase an upgrade to version 12.

download Vitamin-R

Download A Better Finder Rename 12.35

for Intel & Apple Silicon Macs, requires macOS 10.13 or later.

Download A Better Finder Rename 11.53

for Intel & Apple Silicon Macs, requires macOS 10.10 or later.

Download A Better Finder Rename 12.35

for Intel & Apple Silicon Macs, requires macOS 10.15 or later.

Regular Expressions Support in A Better Finder Rename

A Better Finder Rename allows you to use an advanced technique called “Regular Expression Substitution” to match patterns in file names and to rebuild or replace the matched parts.

This is an advanced technique which requires a certain familiarity with programming concepts and may thus prove inappropriate for novice computer users.

The feature is available via the Replace regular expression and the Re-arrange using regular expression actions in the Advanced & Special category. The help topics for either action contain a mini-tutorial on how to get started.

An overview of basic regular expression syntax is available in the Basic Regular Expression Syntax help topic.

Which action to use

  • Replace regular expression replaces every match of the pattern in the name and leaves everything else exactly as it was. Use it to strip, clean up or substitute parts of a name.
  • Re-arrange using regular expression requires the pattern to match the whole name and builds the new name from the substitution alone. Use it to take a name apart into capture groups and put it back together in a different order. The preview table shows the contents of each capture group in its own column.

Capture groups

Parts of the pattern enclosed in brackets are “capture groups”. The text they matched is available in the replacement or substitution as $1, $2, $3 and so on; $0 is the whole match. The older \1, \2, \3 syntax is accepted as well, so patterns written for other tools (or for very old versions of A Better Finder Rename) can be pasted in unchanged.

Case conversion

You can change the case of matched text directly in the replacement or substitution using the escape sequences familiar from sed and Perl:

  • \U — convert all following characters to uppercase until \E
  • \L — convert all following characters to lowercase until \E
  • \u — uppercase only the next character
  • \l — lowercase only the next character
  • \E — end any ongoing case conversion

Examples

  • Replace (.*) with \U$1\E makes apple into APPLE
  • Replace (\w+) with \u$1 makes apple pie into Apple Pie (every word is a separate match)
  • Replace (\w)(\w*) with \u$1\L$2\E makes hELLO wORLD into Hello World

Case conversion requires the modern regular expression engine (see below).

Modern & legacy regular expression engines

Regular expression support has been a feature of the program for two decades, so there are many people who have saved presets and droplets that contain regular expressions written a long time ago.

Since version 12.19 the program contains two engines:

  • the modern engine supports the full ICU syntax including lookahead and lookbehind, adds the case conversion escapes described above and accepts both the $1 and the \1 capture syntax.
  • the legacy engine is the RegexKitLite based engine that earlier versions used. It exists only so that old presets and droplets keep producing exactly the names they always did.

The Replace regular expression action always uses the modern engine.

The Re-arrange using regular expression action has a Use legacy library checkbox. From version 12.34 onwards a newly created action starts with this checkbox unticked, i.e. on the modern engine. Presets and droplets keep the engine they were saved with: an action saved by a version before 12.19 runs on the legacy engine, and an action saved by a later version remembers its own setting. You do not need to do anything to keep old presets working.

Both engines understand the same pattern syntax, which is documented on the ICU website. The one difference in behaviour is described in the Re-arrange using regular expression help topic.

There are number of good regular expression tutorials available on the internet:

[Back to Help Topics]