• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Copy Public Dropbox URLs
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Copy Public Dropbox URLs


  • Subject: Copy Public Dropbox URLs
  • From: Christopher Stone <email@hidden>
  • Date: Tue, 30 Apr 2013 00:08:03 -0500

Hey Folks,

I got ticked off that Dropbox doesn't have the ability to copy public urls to the clipboard via a keyboard shortcut, and so (of course) I wrote a script.

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 Dropbox to copy a url and then put YOUR prefix in dbBaseURL below.

Use your favorite script-runner, and go-to-town.

--
Best Regards,
Chris

-------------------------------------------------------------------------------------------
# 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 dbBaseURL to "https://dl.dropboxusercontent.com/u/00000000/"

  

  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

-------------------------------------------------------------------------------------------

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users

This email sent to email@hidden

  • Prev by Date: Re: Epoch Seconds to YYYY-MM-DD
  • Previous by thread: AUTO: Jin Ming Tsin is out of the office (returning 05/06/2013)
  • Index(es):
    • Date
    • Thread