Slash Boxes
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

use Perl Log In

Log In

[ Create a new account ]

pudge (1)

  (email not shown publicly)
AOL IM: Crimethnk (Add Buddy, Send Message)

I run this joint, see?

Journal of pudge (1)

Monday July 19, 2004
11:56 AM

Stupid Mac::Glue Tricks: Renaming MP3s

[ #19932 ]

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.)

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;

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
More | Login | Reply
Loading... please wait.