How to mass rename/copy/link files in Linux (using mmv and rename)

  • mmv moves (or copies, appends, or links, as specified) each source file matching a from pattern to the target name specified by the to pattern.
$(el) yum install mmv (NUX)
$(deb) apt-get install mmv
$(arch) yaourt -S mmv

# '*.jpeg' -> '*.jpg'
$ mmv '*.jpeg' '#1.jpg'
# '.html.en' -> 'en.html'
$ mmv '*.html.??' '#1.#2#3.html'
  • rename@man/rename@ubuntu is a perl script which can be used to mass rename files according to a regular expression.
$(el) yum install util-linux-ng
$(deb) apt-get install perl
$(arch) pacman -S perl-rename

# '*.php' -> '*.html'
$ rename -n 's/.php$/.html/' *.php
# upper case -> lower case
$ rename 'y/A-Z/a-z/' *
# strip '.bak' extension
$ rename 's/.bak$//' *.bak

from rename@cyberciti and rename@tecmint