Renaming files

In order to mass rename files, you can use the rename command.

Unfortunately there are different versions:

  • one without regex (like on Fedora)
  • one with regex (like on Debian)

The rename command supporting regexp is written in Perl, and thus support regular expressions from Perl

To modify the extension (with regex)

rename -v 's/\.jpeg$/.jpg/' *
rename -v 's/\.bak$//' *

To modify the case (with regex)

rename -v 'y/A-Z/a-z/' *

To modify the extension (without regex)

rename .htm .html *.htm

To dry-run

rename -nv "chanson-de-la-semaine" "song-of-the-week" *