Automator Woes

Discussion in 'Mac Apps and Mac App Store' started by GLaDOSsMD, Mar 5, 2011.

  1. GLaDOSsMD macrumors newbie

    Joined:
    Mar 5, 2011
    #1
    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?
     
  2. speg macrumors member

    Joined:
    Feb 8, 2006
    #2
    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...
     
  3. mysterytramp macrumors 65816

    mysterytramp

    Joined:
    Jul 17, 2008
    Location:
    Maryland
    #3
    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
     

Share This Page