(perl-)rename – a must-have!

http://search.cpan.org/dist/rename/bin/rename.PL

^ This!

Ever did some stupid for i in *.foo; do someconvert $i ${i}.bar; done , and hated the double “.foo.bar” extension? Or started naming files “1-foo“, “2-bar“, reached 10, and had to pad all the filenames with a zero? Hated doing it by hand, or writing stupid bash scripts to do it? Just use rename!

If you call in next 15 minutes, you will get a free…

…yes, yes, i know, but it’s a really useful tool!

Here are some examples stolen from the documentation page:

 rename 's/\.flip$/.flop/' # rename *.flip to *.flop
 rename s/flip/flop/ # rename *flip* to *flop*
 rename 's/^s\.(.*)/$1.X/' # switch sccs filenames around
 rename 's/$/.orig/ */*.[ch]' # add .orig to source files in */
 rename 'y/A-Z/a-z/' # lowercase all filenames in .
 rename 'y/A-Z/a-z/ if -B' # same, but just binaries!

Leave a Reply

Your email address will not be published. Required fields are marked *