Deleting files with Apple script, almost working!

Discussion in 'Mac Programming' started by britishcolumbia, Sep 10, 2009.

  1. britishcolumbia macrumors newbie

    Joined:
    Oct 6, 2008
    #1
    This script is supposed to delete files out of my downloads stack but it doesnt do ANYTHING. no errors, no result, no nothing...
    FYI "The Mothership" is my internal HDD and "Jackman" is my home folder.

    Code:
    tell application "Finder"
    	
    	try
    		
    		delete (every item of folder "Downloads" of folder "Jackman" of disk "The Mothership" whose modification date is less than ((get current date) - 1 * days))
    	end try
    	
    end tell
    
     
  2. moshpitwookie macrumors newbie

    Joined:
    Mar 3, 2009
    #2
    Hi britishcolumbia

    I copied your script and added in the "Users"
    ----------------
    tell application "Finder"

    try

    delete (every item of folder "Downloads" of folder "Paul" of folder "Users" of disk "Macintosh HD" whose modification date is less than ((get current date) - 1 * days))
    end try

    end tell
    ---------------

    it works great! - thanks this is an awesome script!

    cheers
     
  3. mysterytramp macrumors 65816

    mysterytramp

    Joined:
    Jul 17, 2008
    Location:
    Maryland
    #3
    This will work, too ...

    Code:
    tell application "Finder"
    	try
    		move (every item of alias "Macintosh HD:Users:<your user name>:Downloads:" whose modification date is less than ((get current date) - 1 * days)) to trash
    	on error errNum number errMsg
    		display dialog ("Error: " & errNum as string) & return & errMsg
    	end try	
    end tell
    Advantage ... it moves files to the trash to give you an option before deleting them.

    mt
     

Share This Page