Every once in a while, I need to rename a bunch of files. Instead of hand-typing all of the new names, sometimes a nice regular expression would get the job done a lot faster. While there are a couple Windows GUI regular expression file renamers, I enjoy doing as much as I can from the command-line.
Since .NET exposes an easy to use library for regular expressions, I created a small C# command-line app that can rename files via any regular expression.
Usage:
RR.exe file-match search replace [/p] /p: pretend (show what will be renamed)
You can use .NET regular expressions for the search and replacement strings, including substitutions (for example, "$1" is the 1st capture group in the search term).
Examples:
Simple rename without a regular expression:
RR.exe * .ext1 .ext2
Renaming with a replacement of all "-" characters to "_":
RR.exe * "-" "_"
Remove all numbers from the file names:
RR.exe * "[0-9]+" ""
Rename files in the pattern of "123_xyz.txt" to "xyz_123.txt":
RR.exe *.txt "([0-9]+)_([a-z]+)" "$2_$1"
Download
You can download RenameRegex (RR.exe) from here. The full source of RenameRegex is also available at GitHub if you want to fork or modify it. If you make changes, let me know!