Renaming multiple files

We’re all familiar with mv command for simple renaming or moving of files in bash.

I recently however needed to change extension for multiple files; for such task one of the easiest commands is rename, let’s see some examples from the manual:

rename [options] expression replacement file/filter

Given the files foo1, …, foo9, foo10, …, foo278, the commands:

$ rename foo foo0 foo?
$ rename foo foo0 foo??

will turn them into foo001, …, foo009, foo010, …, foo278. And

$ rename .htm .html *.htm

will fix the extension of your html files.

You should also check mmv which can be used for bulk renaming and/or moving.

This is archived version of blog, preventing broken links. This version will stay online indefinitely.