Create a gist now

Instantly share code, notes, and snippets.

Dropbox Screenshot Copy URL via OS X Folder Action

This gist has been moved to its own repo! Please see

Dropbox Screenshot Copy URL via OS X Folder Action


This gist includes a custom Folder Action Script (dropbox-copy-public-url.applescript) that copies to clipboard the public URL of any newly created file inside of ~/Dropbox/Public, and emit a Growl notification.

The installation instructions below install the script into ~/Library/Scripts/Folder\ Action\ Scripts, configure OS X to store screenshots in ~/Dropbox/Public/screenshots (instead of ~/Desktop), and configure OS X to run the script on any newly created file in that folder.

Although the script was written with sharing screenshots in mind, it can be associated with any folder under ~/Dropbox/Public.

The script was adapted from


Download dropbox-copy-public-url.applescript by running the following terminal commands:

# custom Folder Action Scripts go here
mkdir ~/Library/Scripts/Folder\ Action\ Scripts
cd ~/Library/Scripts/Folder\ Action\ Scripts

# downloads the script

Now, find your Dropbox user ID, as follows: In Finder, right-click on any file under ~/Dropbox/Public, choose "Dropbox > Copy Public Link". You'll have a link in your clipboard like, and 12345678 is the user ID.

The following sed command automatically finds and replaces "" with "12345678" in dropbox-copy-public-url.applescript. Modify it with your actual Dropbox ID and run it as follows:

sed -i.bak 's/"<YOUR_DROPBOX_ID>"/"12345678"/' dropbox-copy-public-url.applescript

Folder Action Scripts don't seem to work unless they're converted into Apple's binary scpt format, which is editable via the "AppScript Editor" app. The following converts dropbox-copy-public-url.applescript into dropbox-copy-public-url.scpt and removes the original file:

osacompile -o ~/Library/Scripts/Folder\ Action\ Scripts/dropbox-copy-public-url.scpt dropbox-copy-public-url.applescript
# clean up: remove the original .applescript source files
rm dropbox-copy-public-url.applescript dropbox-copy-public-url.applescript.bak

Non-terminal option: Note, if you'd rather do as little command-line as possible, you can achieve the same thing by manually creating /Users/USERNAME/Library/Scripts/Folder Actions Scripts, opening up "AppleScript Editor", pasting the contents of dropbox-copy-public-url.applescript into a new script, and saving it as dropbox-copy-public-url.scpt in the newly created folder. See Don't forget to find-and-replace <YOUR_DROPBOX_ID> with your actual Dropbox user ID, eg 12345678.

The following terminal commands will tell OS X to store screenshots to ~/Dropbox/Public/screenshots:

mkdir ~/Dropbox/Public/screenshots
defaults write location ~/Dropbox/Public/screenshots
killall SystemUIServer # restarts SystemUIServer to see change

Finally, the following will associate dropbox-copy-public-url.scpt as a Folder Action on ~/Dropbox/Public/screenshots:

  • Locate ~/Dropbox/Public/screenshots in Finder
  • Right click on the screenshots folder, select "Folder Actions Setup..."
  • Select dropbox-copy-public-url.scpt to have it act on all files added to the screenshots folder.

That's it. Now type CMD-SHIFT-4 and take a screenshot, and the dropbox URL should be in your clipboard. If you have Growl installed, the script will trigger a Growl notification.

See for more shortcuts

Security concern

By sharing a link to one of your screenshots (eg you are advertising your Dropbox user ID. Based on this, an attacker can easily guess other URLs for your screenshots, and try them until one works. Keep this in mind when using Dropbox's Public folder.


  • Fix security problem, either by leveraging a dropbox feature, or by randomizing file names in the script.
  • It would be nice if clicking on the Growl notification showed the file in Finder, or maybe open it in for annotations.
  • Consider supporting Google Drive or Box
  • Is there a dropbox API to do this better than hardcoding the URL syntax?

Learn more

on adding folder items to this_folder after receiving added_items
-- almost entirely taken from
set the item_count to the number of items in the added_items
if the item_count is equal to 1 then
set theFile to item 1 of added_items
set theRawFilename to ("" & theFile)
-- theRawFilename == "Macintosh HD:Users:USERNAME:Dropbox:Public:screenshots:FILENAME.ext"
set posixRawFilename to POSIX path of theRawFilename
set pathInsidePublic to (do shell script "echo '" & posixRawFilename & "' | sed 's#^.*Dropbox/Public/##'")
if the pathInsidePublic is not equal to posixRawFilename then
set theWebSafeFileName to switchText from pathInsidePublic to "%20" instead of " "
-- replace <YOUR_DROPBOX_ID> with your actual Dropbox ID (eg 12345678)
set dropboxId to "<YOUR_DROPBOX_ID>"
set theURL to "" & dropboxId & "/" & theWebSafeFileName
set theURL to posixRawFilename
end if
set the clipboard to theURL as text
-- see
tell application "GrowlHelperApp"
-- Make a list of all the notification types
-- that this script will ever send:
set the allNotificationsList to ¬
{"Public URL"}
set the enabledNotificationsList to allNotificationsList
-- Register our script with growl.
-- You can optionally (as here) set a default icon
-- for this script's notifications.
register as application ¬
"CopyDropboxURL" all notifications allNotificationsList ¬
default notifications enabledNotificationsList ¬
icon of application "Dropbox"
notify with name ¬
"Public URL" title ¬
"Dropbox Public Folder Updated" description ¬
(theURL & " copied to clipboard.") application name "CopyDropboxURL"
end tell
end if
end try
end adding folder items to
to switchText from t to r instead of s
set d to text item delimiters
set text item delimiters to s
set t to t's text items
set text item delimiters to r
tell t to set t to item 1 & ({""} & rest)
set text item delimiters to d
end switchText

This gist has been moved to its own repo!
Please see

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