Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@grahams
Last active November 1, 2022 15:31
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save grahams/85e80ab7a59ad5cfd0250397aa4eebd1 to your computer and use it in GitHub Desktop.
Save grahams/85e80ab7a59ad5cfd0250397aa4eebd1 to your computer and use it in GitHub Desktop.
#!/usr/bin/env python3
import sys
import os
import subprocess
from datetime import date
import random
import string
import pathlib
year = str(date.today().year)
def setClipboardData(data):
p = subprocess.Popen(['pbcopy'], stdin=subprocess.PIPE)
p.stdin.write(bytes(data, "utf8"))
p.stdin.close()
retcode = p.wait()
return retcode
for f in sys.argv[1:]:
if((f.find("Screenshot " + year) != -1) or (f.find("Screen Shot " + year) != -1)):
ext = pathlib.Path(f).suffix
rName = ''.join(random.SystemRandom().choice(string.ascii_uppercase + string.ascii_lowercase) for _ in range(6))
destDir = "/Users/grahams/Resilio Sync/Public/Screenshots/"
destName = destDir + rName + ext
os.rename(f, destName)
setClipboardData("http://grahams.wtf/public/Screenshots/" + rName + ext)
cmd = 'osascript -e \'display notification "Screenshot uploaded: \' + rName + ext" with title "Resilio Screenshot Processor"\''
subprocess.Popen(cmd, shell=True)
@grahams
Copy link
Author

grahams commented Jan 31, 2017

I created a Resilio Sync share that is on my desktop as well as a machine running a public web server. When I add files to the share from my local machine, it's mirrored into that public web space. I did this to replicate the Dropbox "Public" folder functionality.

Use this script from a Automator folder action on your ~/Desktop folder. As you use the standard OSX screenshot mechanism, this will trigger the script which will move it to the Resilio public folder and give it a pseudorandom filename.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment