Add current iTunes track to a chosen playlist

Aug 25, '03 09:33:00AM

Contributed by: seven5

Ok, this might not sound all that interesting, but it's all in how you use it! I wrote this very simple AppleScript to tell iTunes to add the song that was currently playing to a specific playlist. I called this playlist "Current Favs." I wanted to be able to add songs to this list whenever I wanted to on the fly. I'll give you the script, then tell you how it is really convenient.

-- Set myList to the name of the playlist to
-- which you wish to add the currently playing song.

set myList to "Current Favs"

property okflag : false

tell application "Finder"
  if (get name of every process) contains "iTunes" then ¬
  set okflag to true
end tell

if okflag then
  tell application "iTunes"      
    set currentList to playlist myList
    add (get location of current track) to currentList
  end tell
end if
Once you've created the script, put it somewhere for safe keeping. I put all my referenced scripts under ~/Applescripts. Now the beauty of this script comes when you use a hot key application like iKey (Youpi Key) to set it to run with the press of a key. I already have F10 F11 and F12 set to prev track, pauseplay, next track respectively, so i set F9 to launch this applescript. Once you hit the key, its all transparent. You see nothing, and iTunes doesn't even gain focus. The track is instantly added to that playlist.

Next, I tell iTunes to use THAT playlist as one of the ones that is synced to my iPod. Now i have an instant key to add songs to my iPod. Whenever I hear a good song and think, 'MAN thats a good song!,' it gets bookmarked for later as well as instantly synced to my iPod once it's connected ... with nothing more than a button push.

Comments (7)


Mac OS X Hints
http://hints.macworld.com/article.php?story=20030823012817924