Label original files using aliases in folder

I based this off another script I found here about replacing aliases with original files, and modified it to my needs. In creating a cross referenced system of thousands of folders, it was very easy to not remember if I had made an alias of a specific folder or not. This script takes all the aliases in a specific folder, finds the original for each and labels it a specific color. Then I could very easily sort out which folders I still needed to cross reference. Hopefully it can help someone else too.

Short. Sweet. Effective.


tell application "Finder"
	set fileList to every file of folder (choose folder with prompt "Choose a folder")
	repeat with i in fileList -- loop through the selected files
		if class of i is alias file then -- make sure we are working with an alias file
			set originalFile to original item of i -- the original file of the alias
			set label index of originalFile to 1 -- change this number to the corresponding label you need (see below)
		end if
	end repeat
end tell

--0 -> No Label
--1 -> Orange Label
--2 -> Red Label
--3 -> Yellow Label
--4 -> Blue Label
--5 -> Purple Label
--6 -> Green Label
--7 -> Gray Label