Skip to content

Instantly share code, notes, and snippets.

@dvessel
Last active August 29, 2015 13:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dvessel/10641867 to your computer and use it in GitHub Desktop.
Save dvessel/10641867 to your computer and use it in GitHub Desktop.
AppleScript to capture screen shots and upload them with SCP.
-- Requires public key encryption setup for the remote server.
-- This also assumes LaunchBar is installed.
property the_url : "http://example.com/path/"
property save_folder : "/Users/bob/Sites/example.com/path/"
property scp_remote : "bob@example.com:/www/example.com/path/"
on run
set tmp_name to do shell script "date +'%Y-%m%d-%H%M%S'" & ".png"
set tmp_path to quoted form of (POSIX path of save_folder & tmp_name)
do shell script "screencapture -i " & tmp_path
set file_name to (do shell script "shasum " & tmp_path & "| awk '{ print $1 }'") & ".png"
set save_path to quoted form of (POSIX path of save_folder & file_name)
do shell script "mv " & tmp_path & " " & save_path
try
with timeout of 10 seconds
do shell script "scp -C " & save_path & " " & scp_remote
end timeout
on error
error "Could not upload to server."
end try
try
set full_url to the_url & file_name
set as_tid to AppleScript's text item delimiters
set AppleScript's text item delimiters to " "
set full_url to text items of full_url
set AppleScript's text item delimiters to "%20"
set full_url to full_url as string
set AppleScript's text item delimiters to as_tid
with timeout of 3 seconds
tell application "LaunchBar"
set selection as text to full_url
activate
end tell
end timeout
on error
error "Whoops! Something went wrong."
end try
end run
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment