Donnerstag, 20. Mai 2010

Link Tracklist metadata to id3-tags

Problem: You have a mp3 album, but the files have no id3-tags set, but you've found a tracklist with the format:

<track-number>. <artist> - <title>

i.e.:

cat tracklist.txt | 
 while read f; do
  tr=$(echo "$f" | sed -e 's/\. .*//');
  a= $(echo "$f" | sed -e 's/...\. \(.*\) - .*/\1/');
  t=$(echo "$f" | sed -e 's/.* - \(.*\)/\1/');
  mid3v2 -T "$tr" -a "$a" -t "$t" -A "100 хитов русского рока" -g 17
    "$(find ./ -type f -iname "${tr}-*")";
 done

We pipe the tracklist 'tracklist.txt' to a loop, which does for each line (mp3-file):
We extract the track# 'tr', the author 'a' and the title 't'.
Then we set the id3v2.4 tags with mutagen mid3vs of the corresponding file - identified by the track#, we get the filename with a find-cmd.
Additionally we set the Album (-A) to '100 хитов русского рока' (100 Russian rock hits).

Keine Kommentare: