Keeping Your Screenshots Organized in OS X
By Daniel Miessler on December 13th, 2008: Tagged as Apple | OS X | Programming | Technology
When you create a screenshot (or “screen capture”) in OS X it’s dropped onto the desktop as a PNG file with name of “Picture 1.png”. And the next one you create drops “Picture 2.png”, etc.
This is cool, but it gets annoying over time–especially if you make a lot of them. The problem is that you can’t just collect them in another folder because as you move them OS X will start over with “Picture 1.png”, and when you go to move them again you’ll be writing over your old ones.
I’ve solved this using two methods (out of curiosity, mostly):
- OS X Automator
- Ruby
Automator

OS X Automator is extremely useful for these types of challenges. Here are the steps on this one:
- Start with a Finder search and pick out the file names and types you’re looking for
- Rename the files to something unique
- Move the files where you want them
- Save the automation as an application
- Run the task whenever you need it, or run it automatically as an iCal event
Ruby

[ruby]#!/usr/bin/env ruby
ScreenCapture Cleanup : Keep your OS X desktop tidy by organizing your screenshots
require ‘fileutils’
Set the text to append to the Screen Captures
timestamp = date
Start on the desktop (that’s where OS X drops Screenshots)
Dir.chdir(‘/Users/daniel/Desktop/’)
Append the date to make the files unique
Dir.glob("Picture*.{png}").each { |pic| File.rename(pic, timestamp + pic) }
Move them to the Screen Captures directory
Dir.glob("Picture.{png}").each { |pic| FileUtils.mv(pic, "/Users/daniel/Documents/Screen Captures/") }[/ruby]
The Ruby method is more elegant, I think, and I hate using GUIs when I don’t know exactly what they’re doing. Plus it’s easier to change quickly.
Executing the Script Automatically
There are three main options here:
- Schedule through iCal : this will happen at that point in time on the calendar
- Enable via Folder Action : whenever something is added to that folder
- Using
launchd: this is kind of like cron for UNIX, only less user-friendly
For iCal just add the Automator script as a file attached to an alert. For Folder Actions, just enable Folder Actions for a given directory and attach your Automator task to it. Either way, now you have a cleaner desktop with less chance of borking up your screenshots. ::