This one is for Randy, who would like to sync his shuffle with a playlist. I went ahead and chose audio-only unplayed podcasts, but feel free to modify as needed. The script includes some oddball uses that work but look ugly. Like the conversion of “none” to string and the use of the floc local variable. Got a better way? See some obviously bad coding here? Let me know in the comments. Thanks go to Mark Hunte for several improvements.

tell application "iTunes"

	-- Create playlist if it does not already exist
	set podString to "Podcast Playlist"
	if not (exists playlist podString) then
		make new playlist with properties {name:podString}
	else
		-- Remove all existing podcasts in playlist
		delete every file track of playlist podString
	end if

	-- Collect every track that has downloaded
	set tracklist to every file track of playlist "Podcasts"

	-- Add audio-only items that are still unplayed
	repeat with eachItem in tracklist
		if ((video kind of eachItem) as string is "none") and ((played count of eachItem) is 0) then
			set floc to location of eachItem
			add floc to playlist podString
		end if
	end repeat

end tell

Here’s Mark’s take on the script:

tell application "iTunes"
	set Shuffle_List to "Pod_Shuffle"
	set Pod_list to user playlist "Podcasts"
	set pod_tracks to location of (every file track of Pod_list whose size is greater than 0)
	if not (exists playlist Shuffle_List) then
		make new playlist with properties {name:Shuffle_List}
	end if
	delete every track of user playlist Shuffle_List
	add pod_tracks to user playlist Shuffle_List
	set view of browser window 1 to playlist Shuffle_List
end tell