A little Dropbox nerdery.
These days I use my Dropbox for as much as possible. I’m in there a lot. I share files via my Dropbox public folder whenever I can.
I also take a lot of screenshots. ‘⇧⌘4’ is permanently engrained in my muscle memory. Whether I’m communicating with colleagues in The Verge newsroom or trolling a friend, screenshots have become an essential part of my daily workflow.
When you share via Dropbox as much as I do, copying screenshots from ~/Desktop to ~/Dropbox/Public and then opening a contextual menu to copy the public Dropbox link to the clipboard is laborious.
Today I decided to find a solution to automate as much of the process as possible.1
The first thing I did was track down an AppleScript to watch my Dropbox public folder for new files and automatically copy the requisite public link to the clipboard whenever a new file appears in the directory. I found my answer in the Dropbox forums. This is the AppleScript:
on adding folder items to this_folder after receiving added_items
try
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)
set tid to AppleScript's text item delimiters
set AppleScript's text item delimiters to ":"
set theFileName to (text item 6 of theRawFilename) as text
set AppleScript's text item delimiters to tid
set theWebSafeFileName to switchText from theFileName to "%20" instead of " "
set theURL to "http://dl.dropbox.com/u/YOUR_DROPBOX_ID_HERE/" & theWebSafeFileName
set the clipboard to theURL as text
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
t
end switchText
Follow these steps to create and enable the AppleScript:
Fire up AppleScript Editor2 and paste in the code above. (You can also download the script via the link in the post on the Dropbox forums.)
Replace
YOUR_DROPBOX_ID_HEREwith your numeric Dropbox ID, which appears in URLs to public links in your Dropbox.
Save the AppleScript.
Copy the AppleScript to
/Library/Scripts/Folder Action Scripts
(You will need Administrator privileges.)Right-click on the Public folder in your Dropbox to open a contextual menu and select Folder Actions Setup

Select your AppleScript from the list that appears and choose Attach.

Check the box for Enable Folder Actions if it’s not already checked.

Congratulations! From here on out, any time you drop a file into the Public folder of your Dropbox, its public link will instantly copy to your clipboard.
But this solution only meets half of my needs. I use my Public folder for lots of different kinds of files, so I have a nested folder called “screenshots” to help keep my Public folder tidy. I needed to find a way to automatically send screenshots to this folder the moment I create them so that I can avoid the trouble of moving the files manually.
Step one: change the default save location for screenshots created using the native Mac OS X keyboard shortcuts from ~/Desktop to ~/Dropbox/Public/screenshots.
In case you don’t know, here are the keyboard shortcuts for taking screenshots in Mac OS X:
‘⇧⌘3’ takes a screenshot of your entire screen.
‘⇧⌘4’ captures an area of your screen selected with the mouse.
Using this shortcut you can also press spacebar to select individual application windows (then click your mouse to take the screenshot). The spacebar method allows you to get a perfect snapshot of a specific window and adds drop shadows. I used this method to create the screenshots in this post.
I’m the kind of nerd who’s very comfortable using the Terminal, but I don’t necessarily know every Unix command or “defaults write” trick by heart. If I want to customize an app or service, the Terminal command I’ll need is often a quick search away. In this case, the commands were straightforward:
defaults write com.apple.screencapture location ~/Dropbox/Public/screenshots
~/Dropbox/Public/screenshots is the exact location of the nested folder within the Public folder of my Dropbox. You should insert the exact path for the folder you want to use, which may be different.
In order for the change to take effect you must follow up with this command:
killall SystemUIServer
If you need to change the location again (or revert back to the default) simply follow these steps and replace ~/Dropbox/Public/ with the path of your choice.
So, let’s review what I’ve done so far:
- I enabled an AppleScript that keeps an eye on my Dropbox public folder and automatically copies the public link for any new file that appears within.
- I changed the default save location for screenshots from the Desktop to a nested folder within my Dropbox public folder.
I’m almost done, but my screenshots folder is not fully automated yet. The AppleScript I used to make my Dropbox a bit more self-aware is very specific. It only watches one folder for one file at a time, which means it does not see files that show up inside nested folders. In order to add the functionality I need to my nested screenshots folder, I need to repeat steps 4 through 7 from the first section of this post. But first, my AppleScript needs two slight tweaks:
Open up your AppleScript and find this line:
set theFileName to (text item 6 of theRawFilename) as textReplace the numeral 6 with the numeral 7:
set theFileName to (text item 7 of theRawFilename) as textAppend your nested directory to the URL in the AppleScript.
Save the script with a new filename (I simply appended screens to the filename). Repeat steps 4 through 7 from earlier, with the follow adjustments: you should right-click on your nested folder instead of your Public folder this time.
And that’s it. From now on, whenever a file is copied to the Public folder in my Dropbox, its public link is autometically sent to my clipboard. Additionally, anytime I take a screenshot, it will automatically be saved to my nested “screenshots” folder and its public link will be copied to my clipboard.
This may only save me an hour or two of empirical time per year, but — more importantly — I’ve eliminated a source of friction in my daily workflow. The rhythm of my work every day will encounter fewer disturbances, which means that over time I can be exponentially more productive.





