tell application "iTunes" set iPodName to "" set syncPlaylists to {"Music", "Podcasts"} repeat with syncPlaylist in syncPlaylists repeat with i from 1 to count of sources if the kind of source i is iPod then set iPodName to name of source i as string set ipodPlaylistId to (first playlist of source iPodName whose name is syncPlaylist) end if end repeat set musicLibraryId to (first playlist whose name is syncPlaylist) --update every track itunes syncPlaylist with data from ipod syncPlaylist repeat with ipodPlaylistTracksCounter from 1 to count of tracks of ipodPlaylistId set ipodTrack to track ipodPlaylistTracksCounter of ipodPlaylistId set ipodTrackData to {name, artist, album, played date, played count, rating, skipped count, skipped date} of ipodTrack set foundTracksInPlaylist to (every track of musicLibraryId whose ((name is item 1 of ipodTrackData) and (artist is item 2 of ipodTrackData) and (album is item 3 of ipodTrackData))) repeat with eachFoundTrackInPlaylist in foundTracksInPlaylist --use try blocks in case of missing data try set played date of eachFoundTrackInPlaylist to item 4 of ipodTrackData end try try set played count of eachFoundTrackInPlaylist to item 5 of ipodTrackData end try try set rating of eachFoundTrackInPlaylist to item 6 of ipodTrackData end try try set skipped count of eachFoundTrackInPlaylist to item 7 of ipodTrackData end try try set skipped date of eachFoundTrackInPlaylist to item 8 of ipodTrackData end try end repeat end repeat end repeat end tell