Changing file label colour based on modification date

Hi everybody,

I’m trying to come up with a script that’ll change the label color of files based on their modification date. Specifically, I’d want this script to label any file on the server (regardless of the folder or subfolder it may be in) as grey so that people know this file needs to be seen and acted upon.

The part I’m stuck on, is to get the script to check all folders and subfolders on a given drive for the files to check their dates… If I set the script to choose a folder, it’ll just label whatever is in that folder, be it a file or subfolder. Here’s what I have so far…

set myFolder to (choose folder) as alias
set theDate to date "Friday, February 1, 2008 12:00:00 AM"

tell application "Finder"
	set label index of (every item in myFolder whose modification date is less than theDate) to 7
end tell

No doubt, I’ll learn something new… and I haven’t done anything in Applescript for about two years now. Any help would be appreciated.

Thanks!

Try this:

set myFolder to (choose folder) as alias
set theDate to date "Friday, February 1, 2008 12:00:0 AM"
tell application "Finder"
	set everyfile to (every file in entire contents of myFolder whose modification date is less than theDate) as alias list
	repeat with eachfile in everyfile
		set label index of eachfile to 7
	end repeat
end tell