The Perl utility for quickly renaming files.
Last updated on 02/06/2005: Small, quick fix to allow regex suffixes such as i (for ignoring case) and g (for global replaces) in the regex. They wouldn't work before, they should now.
I needed something to quickly and easily rename sets of files. Mainly, this need grew from an ever increasing set of poorly named mp3 files that were downloaded. Although I have been using mp3mover for some time, it still occasionally gives me grief. I hacked together a quick and dirty Perl script to take care of some things that mp3mover just wouldn't do for me. I find it pretty useful when trying to get files (again, mainly mp3s) to conform to some kind of standard naming scheme.
The program has only really been tested on a Windows platform, although I don't see any good reason why it wouldn't work on Linux or other *nix based systems.
The command line usage is pretty straightforward:
eren.pl <options> <replace regex> where <options> can be: --filter <filemask regex> : only apply to files matching filter : (default tries ALL files) --preview : don't change files, just preview --help : this help
Any of the options may be abbreviated with a single character option (ie. -p for preview, -f for filter). Running the program with no options will also display the usage.
It is highly recommended that you use the preview option before finally making the changes. This prevents making a silly mistake and botching hundreds of file names!
The following examples serve to demonstrate just how wonderful this little tool is. They may also help the command-line impaired.
Change all files with the "jpg" extension to "gif":
eren.pl -f "/\.jpg/" "/\.jpg/\.gif/" -p
Replace the word "car" in all files with "fastcar":
Change mp3s formatted as "tracknum - artist - song.mp3" to "artist - tracknum - song.mp3", but only preview the changes:
eren.pl -f "/^0/" "/^(\d\d) - (.*) - (.*)\.mp3/$2 - $1 - $3\.mp3/" -p
The utility is a very small Perl script that can be downloaded here:
I recommend placing the file somewhere in your PATH so that it can be used quickly and easily from the command line.
The program probably doesn't work right with paths. It is assumed that the current working directory contains the files to be processed. It should be possible/easy to use a different directory on the command line...I just haven't done it yet. Feel free to make this better and send me a patch. :-)
There's currently no good way to ignore case or specify other options to the pattern matching (ie. 'g', or 'i', etc). It would be nice if the program was more tolerable and could handle these things.
This program is free and contains no license of any kind. Feel free to use it, abuse it, and make millions from it without crediting me in any way. If you make it better, please share it with me and others. I'm not responsible for what this does to your files, don't try and hole me accountable.