Skip to end of metadata
Go to start of metadata

rename or prename is Perl a tool which can rename multiple files using regular expression.
For example: remove underline mark (_) from file name

rename -v 's/_//g' *
-v, --verbose
-n, --no-act

's/_//g' means substitute '_' with nothing (which means remove the '_' mark). Without the 'g' at the end, it will only deal with the first '_' mark in a filename.

Test before action


Usually you should use -n and -v option to test your expression. After you make sure that it works as you expected, remove the -n option to do the real job.

Another example: to rename ??.mp3 files to 0??.mp3

rename -v 's/(\d{2}).mp3/0$1.mp3/' ??.mp3
  • No labels