If you are unfamiliar with regular expressions, please the Regular Expressions Support in A Better Finder Rename help topic first.
This action is specifically intended to allow you to easily re-arrange parts of existing file names using the power of regular expressions to match the different file name parts.
You specify a “pattern” as a regular expression with capture groups and then use the capture variables $1
, $2
, $3
in the “substitution expression” to re-arrange the different parts of the name. A Better Finder Rename shows the
contents of each capture variable in the preview table to help you tweak your settings.
Capture groups and capture variables are explained in more detail in the Basic Regular Expression Syntax help topic.
As a simple example of using this feature, let’s swap the first and the second word of a couple of two word file names.
We start by defining a regular expression with two capture groups, e.g. (.*) (.*)
defines two capture groups with
arbitrary content separated by a space.
The substitution expression
is a string in which we can substitute the variables $1
, $2
, $3
with the content of
the capture group with the same index.
$2 $1
will simply swap the contents of the first and the second capture groups.
hello world
-> world hello
John Smith
-> Smith John
Adding arbitrary text around the capture variables simply includes this text in the new file name, e.g.
Dear Mr $2
in the above John Smith
example would yield Dear Mr Smith
.
The action supports capture variables $1
to $8
. For backwards compatibility with earlier versions of A Better Finder
Rename, the old \1
, \2
, \3
, etc. syntax is still supported, but we recommend using the now standard $1
, $2
,
$3
, etc syntax instead.