Dropbox Magic: Use AppleScript to Automatically Generate a Public URL

I can’t even remember life before Dropbox. This amazing app provides you with cloud storage and synchronization to all your devices. But one thing you can’t do with it is write documents and post them to Dropbox immediately, then grab the public link. When creating documents or spreadsheets, I always need to manually copy the file to Dropbox and then generate a link to share with my peers.

But wait!

If you’re a Mac user, you can leverage AppleScript to handle this for you. Here’s how.

1. Open Spotlight in the top right-hand corner of your Mac screen.
Spotlight icon

2. Type applescript and select AppleScript Editor. AppleScript Editor is the standard for creating an Apple script.

AppleScript Editor window

3. Click New Document and paste the following script in the AppleScript window:

on adding folder items to this_folder after receiving added_items
		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 
            & theWebSafeFileName
			set the clipboard to theURL as text
			display dialog theURL & " copied to clipboard."
		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

In the line that begins “set the URL,” you need to replace the numbers in that URL with your Dropbox code. You can get that code by going to your Public folder in Dropbox and right-clicking on a file to generate a Public Link. Replace “1234567” with yours.

Duplicate contacts killing your productivity? See how Scrubly can help in this 100-second video.

4. Save the script to the following folder: Computer/Library/Scripts/Folder Action Scripts.

Saving script in folder

5. Open Finder and highlight the Public Dropbox folder, then right-click and choose Folder Actions Setup.

Selecting Folder Actions Setup in Finder

6. Select script and click Attach.

Attaching script

7. Click Enable Folder Actions.

Folder Actions Setup window

That’s all, folks! Now drag and drop a file into the Public folder on Dropbox and watch the magic.

Dialog box with link to screenshot

Scrubly social-sharing menu.

Scrubly sign-up.