-
-
mmv mmv is a mass move/copy/renaming tool that uses standard wildcards to perform its functions.
mmv's manual page is quite difficult to understand, I have only a limited understandi ng of this tool. However mmv supports some standard wildcards.
According to the manual the ';' wildcard is useful for matching files at any depth in the directory tree (ie it will go below the current directory, recursively).
An example of how to use mmv is shown below:
The first pattern matches anything with a ".JPG" and renames each file (the "#1" matches the first wildcard) to ".jpg".
Each time you use a \(wildcard) you can use a #x to get that wildcard. Where x is a positive number starting at 1.
|
mmv Homepage |
|
You can find mmv on the web here.
Also be aware that certain options used with mmv are also applicable to other tools in the suite, these include mcp (mass copy), mad (mass append contents of source file
to target name), mln (mass link to a source file).
|
|
Tip: |
|
A Java alternative to mmv which runs on both GNU/Linux and Windows is available, Esomaniac
|
-
rename rename is a perl script which can be used to mass rename files according to a regular expression.
An example for renaming all ".JPG" files to ".jpg" is:
rename 's/\.JPG$/.jpg/' *.JPG
|
- Bash
-
scripting Bash scripting is one way to rename files. You can develop a set of instructions (a script) to rename files. Scripts are useful if you don't have mmv or rename...
One way to this is shown below:
for i in *.JPG;
do mv $i `basename $i JPG`jpg;
done
|
Note that the above came script came from a usenet post. Unfortunately I do not know the author's name.
The first line says find everything with the ".JPG" extension (capitals only, because unix is case sensitive).
The second line uses basename (type man basename for more details) with the '$i' argument. The '$i' is a string containing the name of the file that matches. The next portion of the line
removes the JPG extension from the end and adds the jpg extention to each file. The command mv is run on the output.
An alternative is:
for i in *.JPG;
do mv $i ${i%%.JPG}.jpg;
done
|
The above script renames files using a built-in bash function. For more information on bash scripting you may like to see the advanced
bash scripting guide, authored by Mendel Cooper.