mmv is “program to move/copy/append/link multiple files according to a set of wildcard patterns.” Sounds simple at first, and is once you get the hang of the syntax. I don’t use this very often so I tend to forget the proper syntax and have to dig around for it as there are tons of bad examples available.
Lets say we have a directory of files that are simular and want to change. Here’s an example of a group of mp3’s I made and want to remove the band name from the file name
01 – The Police – Synchronicity I.mp3
02 – The Police – Walking In Your Footsteps.mp3
03 – The Police – O My God.mp3
04 – The Police – Mother.mp3
05 – The Police – Miss Gradenko.mp3
06 – The Police – Synchronicity II.mp3
07 – The Police – Every Breath You Take.mp3
08 – The Police – King Of Pain.mp3
09 – The Police – Wrapped Around Your Finger.mp3
10 – The Police – Tea In The Sahara.mp3
11 – The Police – Murder By Numbers.mp3
I want to rename all of these quickly without having to edit each one, one at a time to the format of “number – song.mp3″, to do that the mmv command would look like this
mmv "* - The Police*" "#1#2"
and the ending result after that is the files looking exactly like I want
01 – Synchronicity I.mp3
02 – Walking In Your Footsteps.mp3
03 – O My God.mp3
04 – Mother.mp3
05 – Miss Gradenko.mp3
06 – Synchronicity II.mp3
07 – Every Breath You Take.mp3
08 – King Of Pain.mp3
09 – Wrapped Around Your Finger.mp3
10 – Tea In The Sahara.mp3
11 – Murder By Numbers.mp3
The wildcards of * are translated to their position number, the first * becomes #1 for the output line. This command supports all the standard command line wildcards of * ? [ ... ] and then there is the addition of ; which makes the command run recursivly. The man page example is pretty desctiptive of the usage ““;*.c” will match all “.c” files in or below the current directory, while “/;*.c” will match them anywhere on the file system.“
Recently Commented