Stupid Mac::Glue Tricks: Renaming MP3s
I've done something like this before, but I figured others might find this to be especially useful.
iTunes Music Store has some of the 9/11 Commission stuff available for free. But the artist is "Unknown", the Genre is "Classical", and the album name and track name are both of the form "9-11 Commission Hearings: $foo", where $foo is something like "NYC Panel Three (5/18/04)". Also, it has the spurious "Track 1 of 1" and "Disc 1 of 1". At least the year (2004) was correct.
So I selected all the tracks in iTunes and changed the genre to "Audiobooks" and the artist and album to "9-11 Commission Hearings", and removed the track and disc information.
Then I wanted to remove the "9-11 Commission Hearings: " from the beginning of the track name, but by hand that's a pain, since there's 38 tracks. Perl and Mac::Glue to the rescue. Remember, change the info in iTunes first, or else modify the script to match the proper "album" value, perhaps by "contains" or "begins_with" instead of "equals".
(For bonus points: rewrite the script below to order the tracks by date information. Also, consider making the artist the name of the speaker or panel. Also, consider doing everything I did by hand in iTunes with this script.)
iTunes Music Store has some of the 9/11 Commission stuff available for free. But the artist is "Unknown", the Genre is "Classical", and the album name and track name are both of the form "9-11 Commission Hearings: $foo", where $foo is something like "NYC Panel Three (5/18/04)". Also, it has the spurious "Track 1 of 1" and "Disc 1 of 1". At least the year (2004) was correct.
So I selected all the tracks in iTunes and changed the genre to "Audiobooks" and the artist and album to "9-11 Commission Hearings", and removed the track and disc information.
Then I wanted to remove the "9-11 Commission Hearings: " from the beginning of the track name, but by hand that's a pain, since there's 38 tracks. Perl and Mac::Glue to the rescue. Remember, change the info in iTunes first, or else modify the script to match the proper "album" value, perhaps by "contains" or "begins_with" instead of "equals".
(For bonus points: rewrite the script below to order the tracks by date information. Also, consider making the artist the name of the speaker or panel. Also, consider doing everything I did by hand in iTunes with this script.)
#!/usr/local/bin/perl
use strict;
use warnings;
use Mac::Glue ':all';
my $itunes = new Mac::Glue 'iTunes';
my $tracks = $itunes->obj(
tracks => whose(album => equals => '9-11 Commission Hearings'),
playlist => 1
);
for my $track ($tracks->get) {
my $name = $track->prop('name');
my $value = $name->get;
(my $new = $value) =~ s/^9-11 Commission Hearings://;
$name->set(to => $new) unless $new eq $value;
}
Leave a comment