Movie Sorter

This script takes items from the specified folder, and will ask you the status of them, and gives then the appropriate Finder Label Color. I use this for marking which movies I like, unwatched movies, and which movies I could delete.


set source_folder to choose folder with prompt "Please select directory."

tell application "System Events"
	set item_list to path of every disk item of source_folder
end tell

tell application "Finder"
	repeat with i from 1 to length of item_list
		--display dialog (item i of item_list)
		if label index of (item i of item_list as alias) = 0 and (last character of (item i of item_list)) = ":" and (first character of (item -2 of my stringtolist(item i of item_list, ":"))) ≠ "." then
			set theresponse to (display dialog "What is the status of " & item -2 of my stringtolist(item i of item_list, ":") buttons {"Could Delete", "Unwatched", "Liked"} default button 2)
			--display dialog button returned of theresponse
			if button returned of theresponse = "Could Delete" then
				set label index of (item i of item_list as alias) to 2
			else if button returned of theresponse = "Unwatched" then
				set label index of (item i of item_list as alias) to 0
			else if button returned of theresponse = "Liked" then
				set label index of (item i of item_list as alias) to 3
			end if
		end if
	end repeat
end tell


on stringtolist(theString, delim)
	set oldelim to AppleScript's text item delimiters
	set AppleScript's text item delimiters to delim
	set dlist to (every text item of theString)
	set AppleScript's text item delimiters to oldelim
	return dlist
end stringtolist
on ListToString(theList, delim)
	set oldelim to AppleScript's text item delimiters
	set AppleScript's text item delimiters to delim
	set alist to theList as string
	set AppleScript's text item delimiters to oldelim
	return alist
end ListToString