Apoligies in advance if this is something really simple…I literally just discovered AppleScript about a week ago. Have been a Mac user since Sept. 09.
I am looking for a script that will move the contents of a folder (specifically, my Downloads folder) to the Trash, and then empty the trash.
Usually, my downloads folder is cluttered up with .pdf’s and other various documents downloaded and it would seem very handy to have a script on my desktop which would replace this process.
Thanks
Model: Late 2009 MacBook Pro 13"
AppleScript: AppleScript 2.1.1
Browser: Firefox 3.5.7
Operating System: Mac OS X (10.6)
The most elegant way to do this for about $20 is to use Hazel because it allows you to be selective about what happens in the downloads folder and when it happens. If you don’t want to spring for that then scripting it is straight-forward but dangerous in my view. Do you really want a script?
Yes, I’m aware of the risks. I don’t keep any inportant documents or files in that folder (at the very least nothing that I can not easily re-download if needed) and I would like to save some time in deleting those files.
If you want it to be a little closer to AppleScript, you can use this:
tell application "Finder"
set myDownloadFolder to ((path to home folder as text) & "Downloads:") as string
set everyDownload to (every item of alias myDownloadFolder)
-- display dialog "You're about to delete " & ((count everyDownload) as string) & " items. Do you wish to continue?" buttons {"No", "Yes"} default button 2 cancel button 1
repeat with i in everyDownload
delete i
end repeat
empty trash
-- display dialog "Done!" buttons "OK" default button 1
end tell