Audio Hijack Pro to iTunes script

Last summer, I wrote a post in which I described an AppleScript that took recordings I made in Audio Hijack Pro, imported them into iTunes, and set the “shufflable” and “bookmarkable” properties so that

The script was used to post-process radio shows recorded from the BBC’s “Listen Again” streaming service. The shows are anywhere from half an hour to three hours long, so excluding them from Shuffle and being able to stop and restart from the same playback position is very handy.

Back then I was manually managing the music on my iPod, rather than having it sync automatically. I’ve since changed to automatic syncing and created a “Radio shows” playlist in iTunes for my iPod to sync with. Audio Hijack Pro is set up to record shows overnight, and the next day I drag them from the “Recently Added” playlist to “Radio shows,” from which they’re copied to my iPod at the next sync.

Last night I realized that I was being stupid and that the show recordings could be put in the “Radio shows” playlist automatically by the same script that sets their shufflable and bookmarkable properties. So I added a line to the “Add Shows to iTunes” script in ~/Library/Application Support/Audio Hijack Pro/Recording Scripts, which now looks like this:

 1:  (* Audio Hijack Script *** (C) Copyright 2003-2007, Rogue Amoeba Software, LLC
 2:  "set shufflable" and "set bookmarkable" lines added on 20070725 
 3:  "add to Radio shows" line added on 20080904 *)
 5:  on process(theArgs)
 7:     --Coerce args to be a list
 8:     if class of theArgs is not list then
 9:         set theArgs to {theArgs}
10:     end if
12:     --Into iTunes ye files shall go
13:     tell application "iTunes"
14:         repeat with theFile in theArgs
15:             set aTrack to (add theFile)
16:             set bookmarkable of aTrack to true
17:             set shufflable of aTrack to false
18:             add (get location of aTrack) to playlist "Radio shows"
19:         end repeat
20:     end tell
22:  end process

As before, the bulk of the script and its overall structure come from Rogue Amoeba’s sample script that comes with AHP. My contributions are only Lines 16-18; Line 18 is the one that I added last night. You can see how to get AHP to call the script by looking at my post from last summer or by reading the “Extending with AppleScript” subsection of the “Advanced Topics” section of the AHP manual.

As is common with AppleScript, the syntax is bizarre. You would think—or at least I would think—that adding a track to a playlist would be done with a line like

add aTrack to playlist "Radio shows"

But no, you have to include the “get location” crap, which I learned by reading this old Mac OS X Hints article from 2003. Have I mentioned how much I hate AppleScript? Read Line 18 and tell me how “English-like” it is.

Anyway, this gets back to a theme I hit on last month: being able to program allows you to write these simple little scripts that make the computer work for you instead of you working for it. This script, most of which was written by Rogue Amoeba, saves me from:

It’s not that doing these things is a terrible burden, but they’re dull and repetitive and the computer should do them for me. With a little scripting, it does.