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

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?

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? :)

Leave a comment

About Steven Haryanto

user-pic A programmer (mostly Perl 5 nowadays).