Daily Archives: July 13, 2011

You are browsing the site archives by date.

Automatically upload screenshots

I take a lot of screenshots and was looking for a way to to the following:

  1. take a screenshot
  2. copy that screenshot with a unique name to my webserver
  3. put the full url to the screenshot in my clipboard

See the method below.

	# create a directory 'screenshot' on the desktop
        mkdir ~/Desktop/screenshot;

	# go to that directory
        cd ~/Desktop/screenshot &&

	# capture a selected part of the screen
        screencapture -ix ~/Desktop/screenshot/$(date +%Y-%m-%d-%H-%M-%S).png &&

	# copy this screenshot to my hosting through ssh with scp
        scp ~/Desktop/screenshot/$(ls | xargs | awk '{print $1}') spoon@crsolutions.be:www.spoon-library.be/screenshots/$(ls | xargs | awk '{print $1}') &&

	# add the url to my clipboard
        echo "http://www.spoon-library.be/screenshots/$(ls | xargs | awk '{print $1}')" | pbcopy &&

	# get rid of this directory
        rm -rf ~/Desktop/screenshot;

Thanks to @davelens for his help. You can also follow his blog