When you need to bulk rename files you can not call "mv *.foo *.bar
" to change the extension of all .foo
files to bar
(because bash resolves wildcards and replaces them with the list of matched files).
This works on linuxes who use the Perl version of the rename
command (like Ubuntu):
rename 's/\.foo$/\.bar/' *
You can also use this to rename other parts of the file, e.g. from flag_en.png
, flag_de.png
etc. to just en.png
or de.png
:
rename 's/^flag_//' *
Note that we used $
and ^
to explicitly look at the end and start of the filenames.
Posted by Arne Hartherz to makandra dev (2011-02-16 14:31)