All items in a folder to label green

Hi, I am fascinated and love the possibilities of scripting but have yet to master it myself. Any suggestions of a book or site for a very, very new beginner?

In the mean time, can someone write me a script to automatically change the label color to green in any folder containing the word “burnt”?

I use retrospect to back up my work drive to another drive but I don’t want to back up items in my burnt folders because I have burnt them to cd.

I have created an automator workflow to do this manually but I would love to have a script to run in the background. I did purchase Script Timer so I could use it to schedule this script to run every hour or so.

Thanks in advance for any help and advice,
cindy in indy

Hi Cindy,

The following AppleScript searches your complete hard drive (well, everything Spotlight knows about) for folders containing ‘burnt’ in their name and then sets the label index of all items found in these folders to green. Of course, depending on the size of your hard drive, execution of this script may take some time:

set command to "mdfind \"kMDItemFSName == '*burnt*' && kMDItemContentType == 'public.folder'\""
set folderpaths to paragraphs of (do shell script command)

repeat with folderpath in folderpaths
	set folderfile to POSIX file folderpath
	tell application "Finder"
		set folderitems to entire contents of folder folderfile
		repeat with folderitem in folderitems
			set label index of folderitem to 6
		end repeat
	end tell
end repeat


thanks martin!

even though i have a six drives mounted, ranging from 320-750 gb each, this script really didn’t take long.

with script timer, i have it set to run every hour
so now i don’t have to manually make sure my burnt files aren’t getting backed up with retrospect!