perlmv: Renaming files with Perl code
perlmv is a script which I have personally been using all the time for years, but has only been uploaded to CPAN today. The concept is very simple, to rename files by manipulating $_ in specified Perl code. For example, to rename all .avi files to lowercase,
$ perlmv -de '$_=lc' *.avi
The -d option is for dry-run, so that we can test our code before actually renaming the files. If you are sure that the code is correct, remove the -d (or replace it with -v, for verbose).
perlmv can also save your code into scriptlets (files in ~/.perlmv/scriptlets/), so if you do:
$ perlmv -e 's/\.(jpe?g|jpe)$/.jpg/i' -W normalize-jpeg
You can later do this:
$ perlmv -v normalize-jpeg *.JPG *.jpeg
In fact, perlmv comes with several scriptlets you can use (more useful scriptlets will be added in the future):
$ perlmv -L
lc
pinyin
remove-common-prefix
remove-common-suffix
uc
with-numbers
Let me know if you have tried out the script.
How is this different from the multiple versions of "rename" (originally included in the eg/ directory in Perl 3) already on CPAN?
http://search.cpan.org/~rmbarker/File-Rename-0.05/rename.PL
http://search.cpan.org/~pederst/rename-1.6/bin/rename.PL
It seems very useful.
Unfortunately, I tried installing it on Windows and the tests failed, so I couldn't try it myself.
I could send you the detailed failure log in case you're interested in trying to fix it.
I love you! Please, marry me. :)
Any chance of putting it in Github? :)
@Nilson: I welcome all bug reports. Haven't been using Windows for a while now, but I'll try the script there.
@Sawyer X: Well, after all, you inspired me to upload more applications to CPAN. :-)
As for github, per your request, git://github.com/sharyanto/perlmv.git
Oops, that github link should've been http://github.com/sharyanto/perlmv . Github noob here. Anyway, did a new release of App-perlmv which mentions the github link.
Btw, I also have an old perlmp3tag script, to which I would like to add the scriptlets feature. I think the scriptlets concept (where we let people store short snippets of code to do something specific, e.g. renaming files in $_, manipulating MP3 tag in $AUTHOR/$ALBUM/$TITLE/$YEAR, etc) can be generalized.
@ilmari: Please see FAQ section of perlmv's POD. In short, perlmv offers recursive, automatic suffix addition in case of conflicts, and scriptlets.