tell application "Finder" set moviesFolder to folder (path to movies folder) set movieCount to the count of files in moviesFolder if movieCount ? 1 then set minutesAgo to ((current date) - (2 * minutes)) set movieFiles to the name of every file of moviesFolder set moviesFolder to moviesFolder as string repeat with i from 1 to movieCount set movieFile to item i of movieFiles if the movieFile contains ".m4v" then set moviePath to {moviesFolder & movieFile} as string set modDate to the modification date of item moviePath if modDate (replaceWithLessThanSymbol) minutesAgo then tell application "iTunes" set userPlaylist to user playlist "EyeTV" add alias moviePath to userPlaylist set movieTracks to (tracks of userPlaylist) repeat with movieTrack in movieTracks set movieTrackName to name of movieTrack as string if movieFile contains movieTrackName then set video kind of movieTrack to TV show set AppleScript's text item delimiters to " - " set tokens to (every text item of movieTrackName) as list set show of movieTrack to item 1 of tokens if the (count of items in tokens) > 1 then set name of movieTrack to item 2 of tokens else set name of movieTrack to the (current date) as string end if set comment of movieTrack to "original track name: " & movieTrackName end if end repeat end tell tell application "Finder" delete item moviePath end tell end if end if end repeat end if end tell