GNU/Linux Command – MMV

mmv — Rename multiple files


MMV is a command-line tool which allows the user to move, rename, copy, append and link large amounts of files with a single command. The tool is especially useful when you need to rename a lot of files that have similar filenames, yet subtle differences.

From pattern

It matches the files using the wild-card(‘FROM’ pattern) you gave to indicate the source file(s). Then it will rename the matched files according to the second argument (‘TO’ pattern) to indicate the destination file(s). The ‘From’ pattern can take all the usual shell wild-cards such as ‘*’, ‘?’ and ‘[]‘. Remember that you need to enclose the patterns with quotes, otherwise they will be expanded by the shell and mmv won’t understand them!

To pattern

The ‘#1′ in the ‘TO’ pattern is a wild-card index. It matches the 1st wild-card found in the ‘FROM’ pattern. A ‘#2′ in the ‘TO’ pattern would match the 2nd wild-card, etc. MMV replaces any occurrences of wild-card indexes with the text for the corresponding wild-card in the ‘FROM’ pattern. Note that ‘??’ are actually two wild-cards, both of which match a single character!

$ mmv "*.tar.gz" "#1.tgz" -- Rename all the file extension from.tar.gz to .tgz $ mmv "file*.txt" "file_#2.txt" -- Insert a underscore in filename. $ mmv "*.txt" "#l1.txt" -- Convert the filenames to lower case. $ mmv "*.txt" "#u1.txt" -- Convert the filenames to upper case. $ mmv -r "*" "#u1" -- Convert dir and file names to upper case.

Read: man mmv

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: