|
(* Copyright (C) 2012 Collin Donnell |
|
|
|
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: |
|
|
|
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. |
|
|
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *) |
|
|
|
-- Set this to the ID that appears in your Dropbox share URLs. |
|
set dropbox_id to "<YOUR_DROPBOX_ID>" |
|
|
|
-- Set up the public folders path, a list to hold shared urls |
|
-- and set AppleScript to seperate items using commas when a list |
|
-- is turned into text. |
|
set public_folder to (path to home folder) & "Dropbox:Public" as string |
|
set dropbox_urls to {} |
|
set AppleScript's text item delimiters to ", " |
|
|
|
tell application "Finder" |
|
set selected_items to selection |
|
|
|
repeat with current_item in selected_items |
|
-- Get the file's name |
|
set current_item_alias to current_item as alias |
|
set file_name to name of current_item_alias |
|
|
|
-- Copy it to the public folder. |
|
copy current_item to public_folder |
|
|
|
-- Percent encode the file name and append it to the path |
|
set encoded_file_name to do shell script "/usr/bin/python -c 'import sys, urllib; print urllib.quote(sys.argv[1])' " & quoted form of file_name |
|
set file_share_url to "http://dl.dropbox.com/u/" & dropbox_id & "/" & encoded_file_name |
|
|
|
-- Add the share URL to the list of shared items |
|
set end of dropbox_urls to file_share_url |
|
end repeat |
|
end tell |
|
|
|
-- Set the clipboard to a comma separated list of the shared items. |
|
set the clipboard to dropbox_urls as text |
Is there an updated version? I don't know my dropboxID and share URLs are with http://dl.dropbox.com/s//, where ID is different for each file.