Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!


Click here to return to the 'Automatically attach color labels to files' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Automatically attach color labels to files
Authored by: ehouwink on Apr 14, '07 09:18:17AM
With this mod, the script will first look for similar files with a different color and apply that color, if not successful, do the original thing.

on adding folder items to this_folder after receiving these_items
	set fileColorList to {oranges:{"mpg", "mpeg", "bmp", "wma", "c", "cpp", "dmg", "doc"}, reds:{"asf", "jpg", "jpeg", "ram", "h", "hpp", "mpkg", "iso", "bin", "ppt", "pps"}, yellows:{"mov", "qt", "gif", "aif", "aiff", "htm", "html", "hqx", "tar", "xls"}, greens:{"mp4", "rgb", "rgba", "pcm", "js", "css", "cgi", "pkg", "gz", "z", "tgz", "pdf"}, blues:{"avi", "tif", "tiff", "mp3", "m", "zip", "eps", "ai"}, purples:{"wmv", "png", "wav", "scpt", "tbz", "bz2", "dat", "txt", "prefs"}, greys:{"rm", "ram", "ra", "psd", "pl", "xml", "plist", "sit", "rar", "rtf", "rtfd", "torrent"}}
	tell application "Finder"
		repeat with myFile in these_items
			try
				set {r, l} to {name extension of myFile, label index of myFile}
				set label index of myFile to (label index of first file of this_folder whose name extension is r and label index ≠ l)
			on error
				if the name extension of myFile is in oranges of fileColorList then
					set label index of myFile to 1
				else if the name extension of myFile is in reds of fileColorList then
					set label index of myFile to 2
				else if the name extension of myFile is in yellows of fileColorList then
					set label index of myFile to 3
				else if the name extension of myFile is in blues of fileColorList then
					set label index of myFile to 4
				else if the name extension of myFile is in purples of fileColorList then
					set label index of myFile to 5
				else if the name extension of myFile is in greens of fileColorList then
					set label index of myFile to 6
				else if the name extension of myFile is in greys of fileColorList then
					set label index of myFile to 7
				end if
			end try
		end repeat
	end tell
end adding folder items to


[ Reply to This | # ]