Thursday, February 24, 2011

Stop the Desktop invasion of screenshots!

As a QA guy I take sh*t tons of screen shots. OS X has an amazing built in screenshot tool that I happily snap away with. Only prolem is that my desktop would quickly run amok with errant screenshots like such:


Eventually I got frustrated with this and decided to look into a screenshot manager and found nothing very promising so I came up with a quick, dirty, cheap, homebrew solution. Here is how it works:
  1. Create a Screenshots folder wherever you like. I chose: ~/martinek/Screenshots/
  2. Open up Terminal and enter the following command: defaults write com.apple.screencapture location /Full/Path/To/Folder
  3. Then logout of your user acount and back in again. I found the instructions here, if so inclined you can change the format of your screenshots as well to jpeg, but I think png works best.
  4. Take a screenshot to verify that its in the new shiny screenshots folder
  5. Personal preference here, but I think it works really well. Drag the Screenshot folder to the right side of the dock. You can then right click on it and choose your sorting options. This leverages OS X's very cool dock UI and makes it easy to find images based upon sorting criteria. 
  6. Next to avoid the excessive screenshot issue create a new folder in the screenshot folder called Archive, or what ever you want really.
  7. Next open Automator, yes really Automator. Start with a new folder action.
  8. Unfortunately Automator has a bug with it trying to detect files that are a day old, so we will use the terminal command option to handle the sorting. Add the Run Shell Script action to the canvas and enter the following command: find /Users/path_to/your/screenshot_folder/* -name "*.png" -type f -mtime +1
    This command looks for all files in the Screenshots folder with the .png extension that are older than one day.
  9. Then add the Move Finder Items action to the canvas and choose your Archive filer as the destination
  10. Next right click on the first action Run Shell Script and add Archive to the file path and change the -mtime to "-mtime +7". This looks for files older than 7 days.
  11. Next add the Move Finder Items to the Trash. I decided that a screenshot older than about a week was worthless.
The result should look like this:
Saving the workflow should automatically save the actions to the respective folders. You can always right click on the folders to disable the workflow. Hope this helps keep some desktops out there a bit tidier.


    No comments:

    Post a Comment