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 ]

Friday August 27, 2004
12:02 AM

More iTunes pain

[ #20590 ]

A while ago I had to clean up some MP3 info for a Teaching Company course. Now I have to do it again.

I have Timothy Taylor's "Economics" lecture series, and I want to listen to them sequentially. My iPod seems to have trouble with that because the tracks have duplicated names, inconsistent names, and so on. I want them to comprise the disk and track number so they line up correctly.

I could have done this with Applescript, but just starting up Script Editor seemed too painful.

use warnings;
use strict;
use Mac::Glue ':all';
my $itunes = Mac::Glue->new( 'iTunes' );
my $playlist  = $itunes->prop(view => window => 1);
my @tracks = $playlist->obj('file_tracks')->get;
foreach my $item ( @tracks )
    my $disk  = $item->prop( 'disc_number' )->get;
    my $track = $item->prop( 'track_number' )->get;
    $item->prop( 'name' )->set( to =>
        sprintf "Lesson %02d-%02d", $disk, $track );

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.