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: tubbyman on Apr 14, '07 11:11:54PM

I forgot to add the accompanying applescript to actively change all of the color labels of all files in any selected folder (and subfolders). To use it, open it in script editor, save it out as an application, and run it. It will process all files in the folder you select. As with the folder action script, feel free to mod the behavior to do anything that you want.






tell application "Finder"
set processFolder to (choose folder with prompt "Select a folder to change label colors") as item

my digDeeper(processFolder)

end tell

on digDeeper(myFolder)
tell application "Finder"
my changeColors(myFolder)
set subFolders to every folder in folder myFolder
if (count of items in subFolders) is greater than 0 then
repeat with thisFolder from 1 to count of items in subFolders
set processSubFolder to item thisFolder of subFolders as string
my digDeeper(processSubFolder)
end repeat
end if
end tell
end digDeeper


on changeColors(myFolder)
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", "torrent", "rtf", "rtfd"}}

tell application "Finder"

try
set (label index of every file of item myFolder whose name extension is in oranges of fileColorList) to 1
end try
try
set (label index of every file of item myFolder whose name extension is in reds of fileColorList) to 2
end try
try
set (label index of every file of item myFolder whose name extension is in yellows of fileColorList) to 3
end try
try
set (label index of every file of item myFolder whose name extension is in blues of fileColorList) to 4
end try
try
set (label index of every file of item myFolder whose name extension is in purples of fileColorList) to 5
end try
try
set (label index of every file of item myFolder whose name extension is in greens of fileColorList) to 6
end try
try
set (label index of every file of item myFolder whose name extension is in greys of fileColorList) to 7
end try


end tell

end changeColors




[ Reply to This | # ]