Rename File Set

Rename File Set is a utility for transforming the name of matching files using the full power of regular expressions. I originally created this program to help organize my mp3 collection, but it has proven to be generally useful.

As I have added features, the program has been extesively refactored. It is DRY and very modular. It is also very well tested. Features can now be added or changed very easily.


Darrick Wiebe


Copyright © 2005 Darrick Wiebe


Distributed under the MIT Licence (see MIT-LICENCE file)

Command Line Interface

There are two entry points to the command line version of the program. The primary one is rfs.rb. rfsd.rb just adds debugging options.


rfs.rb [options] [path] [path] ...

If no path is specified, the current directory is used.

The Four Primary Modes of Operation


List Mode: List all files in the folder


Match Mode: List all matching files but don't make any changes


Testing Mode: Display the results without making any changes


Commit Mode: Actually perform the operation on the target files and display the results. By default, --confirm is turned on, see below.

--search regular expression

This option is required for

Behaviour Modification Options


Ask for confirmation before committing a change with a prompt like:

"./original" => "new_name"? [Yes/No/All/Cancel] (yes) _


"./original" => existing file "new_name"? [Yes/No/All/Cancel] (yes) _

This option is on by default.


Don't confirm changes.

--capture capture number

Specifies which capture in the regular expression should be used or replaced. By default the first capture is used. This option affects all regular expressions used. If the expression has no captures, the whole match is used, and this setting has no effect.

--filter regular expression

Filters out all matching files or directories. Multiple filters may be specified.

--keep regular expression

Filters out all non-matching files or directories. Multiple filters may be specified.


Overwrite existing files. If --confirm is on, the confirmation message will


Make all regular expressions case-insensitive.


Recursively descend into the paths specified.


Iterates through files in reverse order.

Primary Functions

--add number

Add number to the capture.

--count start

Replace the capture with the count. succ is used to increment, so you can use either letters or numbers.


Display Options


The program