(*
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