Menu

AppleScript: Get Every Movie In iTunes

AppleScript can be frustrating, but it’s an easy way to get info out of iTunes. The following is a fragment of a script I’m working on, this part simply gets a record list of every video in the current iTunes window that is a “movie” (the alternatives include music videos and TV shows, among others). Credit goes to some examples I found in Doug’s AppleScripts for iTunes. Boo, however, to a few scripts that are saved as “run only” and can’t be inspected, even for security.

tell application "iTunes"
	set musicLibrary to (get view of front browser window)
	set musicLibraryName to (get name of musicLibrary)
	repeat with t from 1 to (index of last track of musicLibrary)
		try
			with timeout of 5 seconds
				set aTrack to (track t of musicLibrary)
				try
					set mdesc to (get description of aTrack as text)
					set mvkind to (get video kind of aTrack as text)

					if mvkind is "movie" and mdesc is "" then set end of mtracks to {mname:get name of aTrack as text, mdesc:mdesc, mvkind:mvkind, mdbid:get database ID of aTrack}
				end try
			end timeout
		end try
	end repeat
end tell