"Older than" and "Within last"

I don’t have any specific project in mind for this, but is there a quick and easy way to sort files/folders/etc by arbitrary modification dates? For instance, to have a script go in and set the label of every file in a folder that is modified within the last 2 weeks to yellow, the last 1 week to green and older than 3 weeks to red.

it isn’t really hard to code. You have to choose a folder, check the modification date of your files, and to set the appropriate label to it. Show me your script i’ll help you.

You can’t yet literally set the colour of a label, but you can easily apply a label to a file if you know which label has the colour you want. You also need to specify the time periods more accurately. :wink:

But this is the general idea:

set today to (current date)
set today's time to days - 1 -- Omit if you want "today" to mean "now, this very second".

set oneWeekAgo to today - weeks
set twoWeeksAgo to today - 2 * weeks
set threeWeeksAgo to today - 3 * weeks

tell application "Finder"
	set containerFolder to target of front Finder window
	try
		set label index of every file of containerFolder whose modification date comes after oneWeekAgo to 6
	end try
	try
		set label index of every file of containerFolder whose modification date comes after twoWeeksAgo and modification date ≤ oneWeekAgo to 3
	end try
	try
		set label index of every file of containerFolder whose modification date ≤ threeWeeksAgo to 2
	end try
end tell

set oneWeekAgo to today - weeks
set twoWeeksAgo to today - 2 * weeks
set threeWeeksAgo to today - 3 * weeks

Thank you, Nigel. That was the bit I was really curious about. I didn’t know if it was possible to easily specify time in Applescript in terms of days, weeks, months, years, etc. I knew I could do it if I had it compute in seconds, for instance 1,209,600 seconds is 2 weeks and 1,814,400 is 3 weeks, but I was having trouble finding references to weeks, etc. in my dictionary searches. I was probably just looking in the wrong places. Like I said, it was more just a proof of concept idea as something I was curious about.