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.


Create an OSX Service to fix non-functional "Move to DropBox" feature

Like many others I've been frustrated that the DropBox contextual menu has disappeared in OSX Yosemite 10.10 and doesn't seem to be getting updated in a hurry.

Here we can duplicate the DropBox contextual menu's action and even improve on it at the same time, by using the Automator application to create an OSX service, which will have the function of moving a file or folder to your DropBox and then reveal the item for further action.
  1. Open Automator from the Applications folder
  2. Choose to create a new Service
  3. Choose the options Service receives selected: Files or Folders in Finder
  4. Drag the Move Finder Items action from the middle column into your workflow window at right
  5. Select your DropBox folder for the Move Finder Items To: option
  6. Drag the Reveal Finder Items action from the middle column into your workflow window at right
  7. Save the workflow from the File Menu, naming it Move to DropBox. The file when saved ends up in your user's Library/Services folder. You can edit it if you want to change the way it works, or duplicate it and target specific project folders.
Then test it out: right-click a file or folder in the Finder, and choose Move to DropBox from the Services sub-menu. Note that if a file with the same name already exists at the destnation no action will occur.

Please leave a comment if it's helped you. Thanks!

Guy Hemmings

Essex, England.