10.5: Take and upload screenshots via Automator

Jun 16, '09 07:30:00AM

Contributed by: Anonymous

I often take screenshots and upload them for my friends to see -- especially while working on web projects etc. So I created an Automator workflow that does this automagically!

First the workflow snaps the whole screen and saves it to the desktop. Then a bash script is run wich uses ftp to upload the image to the webserver. It then takes the URL of the image and copies it to the clipboard. Lastly it notifies you of the upload via Growl. It has no error handling or anything. This is my first workflow and bash script ever, but it works for me. In Automator, create the following steps in a new blank workflow:

  1. Utilities » Take Screenshot. Use these settings:
  2. Utilities » Run Shell Script. Set Shell to /bin/bash and Pass Input to to stdin. Enter the following code, noting the lines you need to edit:
    #!/bin/sh
    # Author: Simon Ljungberg @ www.nimnim.se
    
    # Edit the 5 lines below to fit your configuration
    # URL will be copied to your clipboard!
    HOST='yourftphost'
    USER='yourusername'
    PASSWD='yourpassword'
    REMOTEFILE='pathtoremotefile(including filename)'
    URL='http://yourdomain.com/screens/screenshot.png'
    
    # If you change this you need to change the rm-line too.
    # For some reason (I'm new at this) I couldn't get the file
    # to disappear when using the variable...
    LOCALFILE='~/Desktop/tmpScreen.png'
    
    ftp -n $HOST <<END_SCRIPT
    quote USER $USER
    quote PASS $PASSWD
    binary
    put $LOCALFILE $REMOTEFILE
    bye
    END_SCRIPT
    
    rm ~/Desktop/tmpScreen.png
    echo $URL | pbcopy
  3. If you have Growl installed, add Utilities » Show Growl Notification. Give it a Title ("Done!") and Description ("Your screenshot has been uploaded") so you'll see a message after the upload is completed.
Alternatively, you could download the script from my server, and then just change the variables in the shell script section of the workflow.

To make this work, you need a web server with FTP access, and note that your username and password are stored in the script. Works for me in 10.5.7; I hope someone can make use of it!

Comments (4)


Mac OS X Hints
http://hints.macworld.com/article.php?story=20090612164009491