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.
I had to do the following:
I can only speak for Debian. The two programs are called
/usr/bin/rename.ul
from theutil-linux
package (hence the .ul suffix)/usr/bin/prename
from theperl
packageThe actual
rename
command works via the 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 overrename
fromutil-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
You can install it using cpan, which is the perl repository similar to pip for python.
Here is a tutorial on using cpan.
If you try to run rename it it looks like this
To install the perl rename you can do the following. You might need to install a few dependencies, you can generally just push enter
That is how you would install the rename from cpan.
Next is to get it working on your system. As you might have more then one rename installed.
When you actually want this one.
I just put it into
/usr/bin/
but with a slight different name to make sure I did not break any existing scripts / programs the depend on the old one.For Debian-family (
.deb
) distros, I recommend @SzG's answer.For RedHat-family (
.rpm
) distros (e.g. Fedora), if your time is precious (like mine), you can download, compile, and install, from source viacpan
in one, terse command:Note: