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
--display dialog myFile as string
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 repeat
end tell
end adding folder items to