The stereo in my car can play mp3 CD’s and use the id3 info in the files to display the artist/title/etc. I decided to grab a bunch of mp3’s from my iTunes library and burn them to CD for listening on my long work commute. The CD played perfectly, but everything was showing up on the display as the file names, not the id3 info. A little research turned up that the stereo only supports id3v1 tags and iTunes only writes id3v2 tags. I found a few apps on the web that would batch fix my labels, but I couldn’t really bring myself to pay for something for such a potentially simple task. Perl to the rescue!
First, I had to install a perl module that my shiny new Mac didn’t come with (depends on fink):
fink install mp3-info-pm
Okay, now to write a quick script that can read the id3v2 tags and write the data as an id3v1 tag.
!/usr/bin/perl
addv1.pl to copy the id3v2 tag to the id3v1 data
use MP3::Info qw(:all); use Data::Dumper; usemp3utf8();
$v2tags = getmp3tag($ARGV[0],2); print “V2 Tags\n”; print Dumper($v2tags); print “Applying V1 Tags…\n”; setmp3tag($ARGV[0],$v2tags); $v1tags = get_mp3tag($ARGV[0],1); print “New Tags:\n”; print “V1:\n”; print Dumper($v1tags); Okay, so that works for one file, but I’ve got well over 2,000 mp3 files in my collection, so…
find ~/Music/iTunes/iTunes\ Music -type f -name '*.mp3' -exec ~/addv1.pl "{}" \;
Enjoy!
Update: Thanks to the admin over at macosxhints.com, I now know that from within iTunes you can just click Advanced->Convert ID3 Tags… Don’t I just feel like an idiot now. Leave it to a guy who made “The Switch” to OSX from Linux, not Windows, to find the hard way to do something.
Post a Comment