I feel a need to warn people about the following post: Although I used it for a long time and it was helpful, something changed in my environment, and now I am getting duplicate files.
For example, the song by Journey shows up twice:
"Who's Crying Now.mp3"
'Who’s Crying Now.mp3'
That second one has substituted the plain ASCII apostrophe with Unicode. Name: RIGHT SINGLE QUOTATION MARK, created as Unicode code point U+2019
Polluting my list of files with duplicates is not what I wanted.
I’ve added another option in the command line to avoid this behavior.
Another exiftool operation: suppose you have a bunch of files named something like this:
01 - String Quartet in B flat Major, 1st movement "Allegro".ogg
02 - Sonata, K. 310, 1st Movement (Mozart - Alfred Brendel).ogg
03 - Asturias_Leyenda (Albeniz - Alirio Diaz).ogg
04 - Massenet: Meditation from Thais (Mischa Elman).ogg
05 - La Coulicam - Rondement (Rameau - Harnoncourt, Lars Fryden).ogg
11 - Sonatine en trio "Modere" (Ravel - Orpheus Trio).ogg
12 - Preludes - La cathedral engloutie (Debussy - Sviatoslav Richter).ogg
13 - Eili, Eili (Mischa Elman).ogg
14 - Simple Fugue (Gr. 1, D. 1) (Bach - Gustav Leonhardt).ogg
15 - A Felicidade from Black Orpheus (Paula Robison).ogg
But really, you want the files to just be named after the Title of the song. You don’t want the leading track number, and if there are any characters in the file name that would cause Windows heartburn (like slashes, colon, asterisk, question mark, etc.), you would like those stripped out too. For example: Massenet Meditation from Thais (Mischa Elman).ogg
Here’s a handy command:
exiftool -charset Latin '-Filename<${Title;}.%le' *.mp3
So we have exiftool which is the utility that does the work. Thank you to Phil Harvey for doing the work to make this easy.
Then we have three parameters:
-charset Latin
'-Filename<${Title;}.%le'
*.mp3
The first parameter says to only use non-Unicode characters.
The third parameter says to work on files with the filename extension of .mp3
The second parameter breaks down like this:
-Filename<
-Filename tells exiftool that it will be updating the file name. The < symbol says that the replacement for the file name will be incoming from the rest of the parameter.
After the < what follows has two pieces: ${Title;} and .%le
${Title;} is the processed text from the metadata variable Title. The leading $ and the { and } with the ; before the closing curly brace serve to strip out any invalid characters found in the title that wouldn’t work as a file name.
.%le appends a file name extension. Technically, .%e is the file name extension, but adding the l makes it lowercase. So we get the Title as the first part of the file name, and the last part of the file name is .mp3 (because we told exiftool only to look at .mp3 files).
- Note that the non-change-making version is
-Testname<(for testing, obviously) ↩︎