less than 1 minute read

rename is a unix tool for batch-renaming files. However, the syntax is not too intuitive. This is just a collection of useful snippets.

Rename all files to pattern

Resulting filename is Prefix 01.

rename -n 's/.*/our $i; sprintf("Prefix %02d", 1+$i++)/e' *