Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

GLaDOSsMD

macrumors newbie
Original poster
Mar 5, 2011
1
0
I'm trying to make a folder action in Automator by which my Downloads folder will only keep files that were created within the last seven days, moving older ones to a different location.

Setup:
Get Finder item "Downloads,"
Get folder contents,
Filter Finder items where date created is not in the last 7 days, and
Move Finder items.

The problem is in the Filter Finder items. (http://cl.ly/0Q1v1X1q0K3x0Q0c0u1d). Finder items which were created today still somehow are registered as "not created in the last 7 days." Is this a nasty Automator bug?
 
I just ran into the same problem today. The items DO show up if you choose "today" but not "in the last x days..."

HMM...
 
I had issues with Automator too. How does this work?

Code:
set TID to AppleScript's text item delimiters
set AppleScript's text item delimiters to "/"

set dlFolder to path to downloads folder

set curTime to the current date

set curTime to curTime - (7 * 24 * 60 * 60) -- a week ago

set newPlace to choose folder with prompt "Where do you want your files to go?"

set newPlacePosix to POSIX path of newPlace

tell application "Finder"
	set listOfFiles to every file in dlFolder whose creation date is less than curTime
	
	repeat with aFileAlias in listOfFiles
		
		set aFilePath to the POSIX path of ((aFileAlias) as text)
		set aFileName to text item -1 of aFilePath
		
		set qFilePath to quoted form of (newPlacePosix & aFileName)
		
		set qOrigPath to quoted form of aFilePath
		do shell script "mv " & qOrigPath & " " & qFilePath
		
	end repeat
end tell

set AppleScript's text item delimiters to TID

mt
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.