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.
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.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.
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(.*) with \U$1\E makes apple into APPLE(\w+) with \u$1 makes apple pie into Apple Pie (every word is a separate match)(\w)(\w*) with \u$1\L$2\E makes hELLO wORLD into Hello WorldCase conversion requires the modern regular expression engine (see below).
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:
$1 and the \1 capture syntax.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: