Shell Script to Control iTunes

For mother’s day, one of my wonderful wife’s requests was to have a bit of a Ms. PacMan marathon.

So, out came the ghetto arcade controller and, a bit longer than expected later, a Ms. PacMan marathon she had! (A bit longer because a nasty latency bug has cropped up in MAME OS X somewhere along the way. I found a workaround. But, yuck.)

Now, MAME is full screen and pausing the game just to deal with iTunes shuffle play song selection suckage (since iTunes on the MAME machine sends tunage to the garage workspace) is not considered good gaming etiquette.

Clearly, I need a shell script to control iTunes. Remote Buddy is cool, but it is too slow, requires too much configuration, and, after much use, has proven a bit flaky. A simple, straightforward, shell script is sufficient and, certainly, I cannot have been the first too think of this.

I wasn’t! I found this ancient hint on

David Schlosnagle — who seems to have disappeared — wrote a very useful little shell script that can play, pause, go to the next track, and set the output volume. The script, as posted, doesn’t quite work all the time due to (I presume) shell changes between 10.0(?) and Leopard.

So, I grabbed a copy of the script, dropped it in my hacques repository, and have updated it for Leopard. I also added the ability to set ratings from the command line (and the status command will show the currently playing track’s rating). Minor changes, really.

The latest version can always be had at

Thanks to David for doing this in the first place!!

One Response to “Shell Script to Control iTunes”

  1. David Schlosnagle says:

    So I’m catching up on my Apple related feeds in NetNewsWire and all of the sudden I see your post on the iTunes script I wrote way back in college. I’m glad the script works for you and thanks for updating it. The funny thing is my manager at work was in search of a similar script and ended up finding the same hint, so bonus points in his book.

    I haven’t actually disappeared, though I guess it’s been 2 years since my last blog post and 3 since any real activity. I’ve been on a blogging hiatus as I’m busy with family, work, and relaxing.

    Bill, keep up the excellent posts especially the Objective-C tips and electronic hacks.

Leave a Reply

Line and paragraph breaks automatic.
XHTML allowed: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>