12.24.07

Using Track Parser

Posted in music, programming, web at 12:27 pm by danvk

pitchfork-tracks.png Pitchfork Media has released their two standard year-end lists, the Top 100 Tracks of 2007 and the Top 50 Albums of 2007. As usual, they’ve been lampooned all over the web, including one critique in pie chart form. For me, they made for perfect listening on a long car drive this weekend.

In my case, this list led to a good use of my Track Parser script, which is in all likelihood the most useful program I’ve ever written. It’s an AppleScript for iTunes (i.e. Mac only, sorry) that lets you apply regular expressions to track names/tags. Here’s how I used it today…

Through some strange turn of events (certainly nothing to do with this), I found myself with a playlist of the top 100 tracks. The music was all there, but none of the songs had their “Artist” field filled in! Here’s where my Track Parser script came in.

I googled around and quickly found this page, which has some commentary on the list, as well as what we’re interested in: a copy of all the songs/artists in simple text form. (For what it’s worth, I agree with his reactions.)

I copied the list and ran two regular expressions to get it down to just the artist (s/ ".*//g and ^\d*: if you must know). The tracks are in reverse order of what we want (100 to 1 instead of 1 to 100). So I ran pbpaste | tac | pbcopy to put the #1 track at the top of the list. Or I would have, if Mac OS X had the tac command. Instead, I ran this monstrosity:

pbpaste | perl -ne 'push @x, $_; END { print for reverse @x }' | pbcopy

to do the same thing. In retrospect, I should have just sorted my playlist in reverse track order.

Next I went into iTunes and selected my songs. I ran “Track Parser (Clipboard)” from the Scripts menu, clicked “New Pattern” and put in “%a” to extract the artist from each line. Track Parser handled the rest. Total time: about five minutes.

8 Comments

  1. matt said,

    January 8, 2008 at 11:04 am

    i emailed you a while back about track parser.. just want to say thanks again for it, i use it pretty much every time i’m in itunes lately. actually i’ve whittled down your version a bit, i don’t really use the saved expressions so now i can call it up w/ a shortcut, enter my regex, and i’m done. but i’d be lost w/o the core of the script you’ve put together.

    cheers,
    matt

  2. Wolf said,

    February 4, 2008 at 8:00 am

    While google’ing your name for a home page and maybe updated version of track parser I came across your site, and got stuck at your blog. After reading a couple of nice entrys this one popped up, reminding me about why I was here… ;-)

    Thanks for sharing Track Parser with us. In the last two years it silently replaced almost all other plugins I used to straighten out track information.
    And thanks for giving it out as source code; by looking at it’s innards I even learned something about AppleScript, which still eludes me most of the time, though.

    Thanks. Thanks very much!

    Cheers from Germany.

  3. Jose Galdamez said,

    March 12, 2008 at 6:56 am

    I too have gotten great use from Track Parser. I originally downloaded it from Doug’s Applescripts for iTunes. It is hands down the most powerful tag manager out there. I’d probably get even more use out of it if I’d just take some time to learn regex.

    I do have a question about the “Parser (Clipboard)” script. Is there a way to remove a saved pattern from the main menu?

    Thanks,
    Jose

  4. Chris Cleeland said,

    March 14, 2008 at 3:24 pm

    First, I echo the thanks for such a cool script. Last night I tried to send you an email at Rice and it bounced. I was trying to send the email b/c I was having problems and I was trying to figure out if it was possible to use track parser to do something specific.

    In the first case, today I figured out the problem, and have discovered what may be a bug in the script. I can describe the whole thing in detail if you contact me.

    In the second case, track parser mostly focuses on taking hunks of information that have been glommed together into track names and parsing up and out to their proper fields. In my case, I actually want to add some of those fields back *in* to the track name; is that possible? Specifically, I want to add the “album name” at the beginning of the track name, separate by a comma. This is because what I am actually working with are chapters from an audio book, and the way that the iPod presents audiobooks is slightly different from the way it presents music.

  5. Steve Madancy said,

    June 29, 2008 at 11:24 am

    Oops…Hi Dan, I just left you a comment about Track Parser on your “about” page — I was looking for a general e-mail address. I’d delete it and move it here, but I don’t know how…sorry.

    – Steve

  6. Tom Strand said,

    October 1, 2008 at 5:44 pm

    Track Parser is wonderful!

    I’m wondering if the substitute (album) pattern quit working because of recent iTunes changes? Maybe “album” is name somehting internally now?

    I’m trying to parse the Disc number from the album track (for an 18 CD set, but I get the following error:

    Can’t get every item of “l”.

    I saw note of an open source Track Parser, but can’t find it to see if the “l” needs to refer to a new element in recent iTunes…

    Yes this is (still) very useful software.

    Tom

  7. Wolf said,

    May 8, 2009 at 12:45 pm

    Hi,

    I’ve checked and rechecked, but since iTunes v8.x Track Parser is not working anymore. The entry at Dougs AppleScripts hasn’t been updated since 01/2005 so I came here again to see if there’s any news about an upgrade or a workaround / fix.
    I wasn’t really expecting something, since I myself would probably not be updating a script this old. But then, this things is indispensable for me – and maybe for somebody else too.
    Any way you could be persuaded to have a look at it? AppleScript is still AS. iTunes has maybe modified some parameter or what that has the script falling over. Maybe even easy to fix. And it would make me happy. Very much so. :-)

  8. Steve said,

    May 13, 2009 at 5:52 pm

    Hello,

    I’m having the same problems that Tom and Wolf are having; it looks as though iTunes 8 has broken the script in places. Track Parser is sooooo useful….I’d be eternally grateful if you could update the script sometime!

    Many thanks for a wonderful tool,

    Steve