I run mine from FastScripts and use it to work around the Lion/ML Finder-selection bug, but the script below defaults to using the SystemUIServer for the work-around. (Change as necessary.)
Use your favorite script-runner, and go-to-town.
-------------------------------------------------------------------------------------------
# Auth: Christopher Stone
# dCre: 2013-04-29 : 23:22
# dMod: 2013-04-29 : 23:37
# Appl: Finder & Script-Runner
# Task: Copy Public Dropbox Urls from selected files to the Clipboard.
# Deps: None
# Tags: @Applescript, @Dropbox, @Public, @URL, @Clipboard
-------------------------------------------------------------------------------------------
try
set dbPubStr to ((path to home folder as text) & "Dropbox:Public:")
# Work-around for Lion/Mountain Lion Finder-selection bug:
tell application "SystemUIServer" to activate
# Alternates:
# tell application "FastScripts" to activate
# tell application "Keyboard Maestro Engine" to activate
# YOUR public dropbox prefix:
set {oldTIDS, AppleScript's text item delimiters} to {AppleScript's text item delimiters, "/Dropbox/Public/"}
tell application "Finder"
activate
set _sel to selection as alias list
if _sel ≠ {} then
set hfsPath to item 1 of _sel as text
if (hfsPath does not contain dbPubStr) or (hfsPath = dbPubStr) then
error "Selection not in Public Dropbox folder."
end if
repeat with i in _sel
set contents of i to (dbBaseURL & (text item 2 of (get i's URL)))
end repeat
set AppleScript's text item delimiters to linefeed
set _sel to _sel as text
set AppleScript's text item delimiters to oldTIDS
set the clipboard to _sel
end if
end tell
on error e number n
set e to e & return & return & "Num: " & n
tell me to set dDlg to display dialog e with title "ERROR!" buttons {"Cancel", "Copy", "OK"} default button "OK"
if button returned of dDlg = "Copy" then set the clipboard to e
end try
-------------------------------------------------------------------------------------------
Bonus: Open your public Dropbox folder.
-------------------------------------------------------------------------------------------
# Auth: Christopher Stone
# dCre: 2012-12-11 : 17:52
# dMod: 2013-04-30 : 00:05
# Appl: Finder
# Task: Open Public DropBox folder.
# Deps: None
# Tags: @Applescript, @Dropbox, @Open, @Public
-------------------------------------------------------------------------------------------
try
set dropBoxPublicFolder to alias ((path to home folder as text) & "Dropbox:Public:")
tell application "Finder"
open dropBoxPublicFolder
tell front window
if its bounds ≠ {0, 44, 844, 1196} then
set its bounds to {0, 44, 844, 1196}
end if
end tell
end tell
on error e number n
set e to e & return & return & "Num: " & n
tell me to set dDlg to display dialog e with title "ERROR!" buttons {"Cancel", "Copy", "OK"} default button "OK"
if button returned of dDlg = "Copy" then set the clipboard to e
end try
-------------------------------------------------------------------------------------------