Organising screenshots with Hazel and CloudApp

Ben - Sun 04 November 2012 - hazel, automation, cloudapp

To help clean up my desktop, I've created a little Hazel rule to hide theses pesky screenshot files away. The issue I had, was that I use CloudApp to automatically upload screenshots and I didn't want to lose that. Luckily, there is a Ruby API called cloudapp_api which can upload a file via a Ruby script.

The result is this:

Before setting up Hazel, you will need to install the cloudapp_api. To do this open up Terminal and enter

$ sudo gem install cloudapp_api

Now back to Hazel, let me walk through what I did.

1: Search for files that contain the words "Screen Shot" (OS X names screenshot files like this "Screen Shot 2012-11-04 at 12.25.43.png") and is a png.

2: I really don't need to know it's a "screenshot". Next Hazel renames the file to just a simple date and time stamp. e.g 2012-11-04_1.30.48.png

3: Move the file to a screenshots folder I made in my pictures folder.

4: Now to get the CloudApp upload working. Add a "Run shell script", make sure that the shell is set to "/usr/bin/ruby" and paste: (or download from here)

require 'rubygems'
require 'cloudapp_api'

#Replace with your username and password
CloudApp.authenticate "USERNAME", "PASSWORD"

#Get file from hazel
file = ARGV[0]

#Upload file to CloudApp
@drop = CloudApp::Drop.create :upload, :file => file

#Copy file URL to clipboard
IO.popen('pbcopy', 'r+').puts @drop.data["url"]
puts @drop.data["url"]

exit 0

5: Final step just for fun, is to add a little bit of applescript to play sound when it's complete.

do shell script "afplay '/System/Library/Sounds/Glass.aiff'"

All done!