Windows command-line regular expression renaming tool: RenameRegex

January 30th, 2012

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.


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).


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"


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!

  1. Phil Quinn
    February 1st, 2012 at 04:44 | #1

    Hi — thanks for this. I noticed a small typo in this line: Rename files in the pattern of “124_xyz.txt” to “xyz_123.txt”:

  2. February 1st, 2012 at 09:16 | #2

    Thanks Phil, great catch! Fixed the post.

  3. Wesley
    February 1st, 2012 at 18:31 | #3

    Is there any chance to make it go into folders recursively? Thanks

  4. February 2nd, 2012 at 10:14 | #4

    It doesn’t currently, but that would be a fairly simple update to the code. Are you comfortable making changes? Feel free to contribute edits at, or even just open an issue there as a feature request.

  5. Giri
    June 12th, 2012 at 23:11 | #5

    For the fist case, windows rename command can do the job.
    See rename file extensions

    For all other cases, this tool would help.

  6. CZNeo
    October 8th, 2012 at 11:31 | #6


    I need to rename a couple of files that would contain only the lowercase english chars (ie. ŽČs.jpg -> zcs.jpg)

    Is that possible?



  7. October 8th, 2012 at 11:46 | #7


    The app currently ignores case in the RegEx, but you can change this line 56 in Program.cs:

    // rename via a regex
    string fileNameAfter = Regex.Replace(fileName, nameSearch, nameReplace, RegexOptions.IgnoreCase);

    To remove RegexOptions.IgnoreCase:

    // rename via a regex
    string fileNameAfter = Regex.Replace(fileName, nameSearch, nameReplace);

  8. WCWedin
    February 5th, 2013 at 14:02 | #8

    I’m commenting to say that this little program perfectly met my needs in a minor emergency and got me out of a tight spot! Thanks!

  9. Herm
    March 17th, 2015 at 15:40 | #9

    Thanks Much! Great simple batch rename utility, helps a lot as GUIs couldnt rename/replace extensions that needed to be truncated

  10. ozz
    June 7th, 2015 at 08:12 | #10

    nice tool. I like it.
    btw. the code seems to be updated, but the binary unfortunately not. *hint*

  1. No trackbacks yet.