Ant Renamer 2 Help

Ant Renamer 2

Regular expressions

Ant Renamer uses the TRegExpr library. You can find a syntax reference on the site dedicated to this library. These expressions are quite complex but also quite "standard", so I won't make here a detailed guide explaining how they work.

For the "Regular expression" action, you have to provide two values:

  • Expression, containing a valid regular expression;
  • New name, containing the new name of the file, with $nn backreferences (nn being a number) to indicate where found strings have to be inserted. Note: these backreferences are presented with "\" instead of "$" on the syntax page mentionned above.

Lots of non-alphanumeric characters have a special meaning in regular expressions. To use them, the escape character is the backslash ("\"). This also applies to the "$" sign that has a special meaning in the "new name" field. If you need to use the backslash as a character (e.g. as path delimiter in the new name) you have to double it ("\\").

Examples

Swapping artist and title from mp3 file names:

  • Expression = (.*) - (.*)\.mp3
  • New name = $2 - $1.mp3

Extract episode number and title from series video files with episode number as SnnEmm followed by title:

  • Expression = Code\.Quantum\.S([0-9]{2})E([0-9]{2})\.(.*)\.FRENCH.XViD\.avi
  • New name = Code Quantum - $1$2 - $3.avi