Renaming files at the command line
Command Line – Bulk Renaming

© Lead Image © Golkin Oleg, 123rf.com
When it comes to renaming multiple files, the command line offers time-saving options in the form of mv, rename, and mmv.
Modern computers are full of collections of photos, music, files, and ebooks. These collections increase the need for efficient file management, including the renaming of files. Often, users want to show by naming conventions that a set of files belong together, or, in the case of music files, to ensure that songs are played in a certain order. Similarly, projects may want to indicate file contributors or revision numbers. Fortunately, the Bash shell includes three standard commands for adjusting file names: mv
, rename
, and mmv
.
Desktops routinely include a file manager, in which a file's name can be altered in the same dialog window as its other properties. However this feature is designed for renaming a single file in the simplest of circumstances. Even more importantly, as I found while digitizing music ripped from cassettes, when you work with multiple files, opening and closing the file properties dialog a dozen or more times becomes tedious after a few repetitions. Almost always, it is far easier to open a command line.
At the prompt, you could use a script, especially if you are doing a routine operation like a dated backup. However, even easier is to place all the files to be renamed in the same folder and use their path and a regular expression – probably an asterisk (*) – to rename the files all at once. You do have to be careful that a typo does not leave your file names in confusion, but you can use some of the built-in safeguards and do in a couple of minutes what might take you 10 minutes from the desktop.
[...]
Buy this article as PDF
(incl. VAT)