Wednesday 5 November 2014

Tidy up that messy Downloads folder with Applescript

You can use Apple's scripting language for some very useful tasks. Here I am gathering all of the mess in my Downloads folder into one folder and labelling the folder with today's date.

Select the following text:




set foldername to ("Downloads " & short date string of (current date))
set docsfolder to (path to documents folder) as string

tell application "Finder"
if not (exists folder (docsfolder & foldername)) then
make new folder at docsfolder with properties {name:foldername}
end if
move items of (path to downloads folder) to folder (docsfolder & foldername)
end tell
tell application "Finder"
move folder (docsfolder & foldername) to (path to downloads folder)
end tell



Open the Script Editor from your Utilities folder and paste the text into the 'untitled' window. Click "Compile" and then click Run if you would like to test it directly.
You can save the script as an application, placing that somewhere convenient to run when your downloads folder clogs up again. Choose File Menu... Save, and from the File Format menu choose Application.

The script works by first creating a folder in the Documents folder, then moves all the contents of the Downloads folder there, then moves that folder back into Downloads.


No comments:

Post a Comment