I love Larry Wall's rename command. It makes renaming files so much easier. I no longer have to think about it, I just do it, and it takes 15 seconds to rename an entire directory.
Except when there's a version control system involved. Subversion requires
svn rename and Mercurial wants
and Git wants
and really, it's such a pain.
Faced with a long list of Subversion renames, I finally sat down and wrote
a script to give me
rename's interface with other VCSes. And
since other people might find it useful, I'm posting it here as open source.
On Windows systems, you'll want to add a
On UNIX systems, you'll want to update the first line to point to the
which perl and mark it executable
chmod +x xre).
I keep mine in
~/bin/, which is in my
xre works as follows:
xre [OPTION] COMMAND PERLEXPR [list of strings]
COMMAND is a command to run.
PERLEXPR is a perl expression that modifies the
It simply loops over the list of strings and executes the command once per string with two arguments appended: the original string and its modified version.
A typical invocation is
xre 'hg mv' 's/htm/html/' *.html(Run
hg mv on each filename shell-expanded from *.html, with first argument as the original filename and the second replacing “htm” with “html”.)
If you're unsure, just run
xre at the command line
and it will tell you how it works.
-p option prints without executing
in case you want to double-check;
-v prints while executing
so you can see what it's doing.