Automat(or)ed Screenshot/File/Whatever Uploading

Every so often I clean up my desktop and have to sort through a large selection of "Picture X.png" from various screenshots I have taken to submit as a bug reports and that's annoying, as well as having to rename the screenshot and upload it to my server in the first place.

Automator, with the help of a shell script, has provided a wonderful solution. I ended up with 3 separate utilities.

  1. A simple shell script I named 2server that scps a file (normalizing the name in the process to remove annoying characters), copies the resulting web url to your clipboard, and outputs the web url.
  2. An Automator workflow as a Finder plugin named f2server that sends the selected files through 2server.
  3. The best of all, a workflow called s2server (I use it via Quicksilver) that has you select an area to screenshot, saves it to a directory under a name you specify, and then passes it through 2server. Vwalla, instant screenshot to link to.

All the parts are extremely simple.

2server

#!/bin/sh
OUTFILES=""
for x in "$@"
do
    FNAME=`echo "$x" | sed "s/.*\\///" | /Users/andy/bin/normalize`
    scp -q "$x" term.ie:www/data/$FNAME
    RNAME="http://term.ie/data/$FNAME"
    OUTFILES="$OUTFILES $RNAME"
done
echo $OUTFILES | pbcopy
echo $OUTFILES

(my normalize script, edit to taste)

#!/bin/sh
while read line
do
    echo $line | sed "s/[^[:alnum:]\\.]/_/g" | sed "s/_\\{1,\\}/_/g"
done

2server.workflow screen_2server.workflow.png

f2server.workflow screen_f2server.workflow.png

s2server.workflow screen_s2server.workflow.png

Enjoy :)