Autofill the iPod Shuffle with podcasts via AppleScript

Mar 18, '09 07:30:00AM

Contributed by: gaylward

For inexplicable reasons, Apple seems to have deliberately disabled the autofill function for podcasts on iPod Shuffles in iTunes 8.1. The following script replaces the autofill functionality. If you place the script in your user's ~/Library » iTunes » Scripts folder, it will appear in the Scripts menu of iTunes, making it relatively simple to use.

(*
Script to replace autofill function for iPod shuffle in iTunes 8.1

Deletes all current tracks from attached iPod shuffle, then loads it with contents of a smart playlist

© G W Aylward 2009
*)

-- Set name of smart playlist and shuffle here
set playlistName to "Latest Podcasts"
set shuffleName to "Bill iPod Shuffle"

-- Delete all tracks from iPod shuffle
tell application "iTunes"
  
  -- Find iPod and delete all tracks
  repeat with thisSource in sources
    if the name of thisSource is shuffleName then
      
      -- Get shuffle playlist and delete all tracks from it
      set shufflePlaylist to first playlist of thisSource
      delete tracks in shufflePlaylist
      
    end if
  end repeat
end tell

-- Give time to 'recover' from delete before starting to copy
delay 5

-- copy chosen playlist to iPod shuffle
tell application "iTunes"
  
  set smartPlaylists to (get every user playlist whose smart is true and special kind is none)
  repeat with thisPlaylist in smartPlaylists
    if name of thisPlaylist is playlistName then
      
      display dialog "Copying playlist " & name of thisPlaylist giving up after 1
      duplicate (every track of thisPlaylist) to shufflePlaylist
      
    end if
  end repeat
  
end tell
[robg adds: I haven't tested this one.]

Comments (1)


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