Get the Perl rename utility instead of the built-in rename

WorldsEndless picture WorldsEndless · Mar 22, 2014 · Viewed 16.8k times · Source

Many sites (including various SO articles) talk about using "rename" using Perl expressions to rename files.

This would be perfect, but apparently this is not the rename utility I have, and none of these articles seem to comprehend that there are multiple versions of "rename" and I can't seem to find where to get version that accepts Perl expressions.

How can I get my hands on the more powerful rename utility mentioned here, here, and here?

I'm running Fedora 20. My current rename command is from the util-linux package and apparently I need the Perl version, which is better.

Answer

SzG picture SzG · Mar 22, 2014

I can only speak for Debian. The two programs are called

  • /usr/bin/rename.ul from the util-linux package (hence the .ul suffix)
  • /usr/bin/prename from the perl package

The actual rename command works via the /etc/alternatives mechanism, whereby

  • /usr/bin/rename is a symlink to /etc/alternatives/rename
  • /etc/alternatives/rename is a symlink to /usr/bin/prename

The same problem has been bugging me on Cygwin, which is a Red Hat product, so should be more similar to Fedora. I'll have a look on my company laptop on Monday. And I remember the Perl-rename having worked there sometimes. Probably before I installed util-linux.

If you install the Perl-rename to /usr/local/bin it will have precedence over rename from util-linux. Same goes for the manpage when installed to /usr/local/share/man/man1/.

I've just created a separate Perl-rename package on Github: https://github.com/subogero/rename