Post to Dropbox Service
Author: Oliver Stengele (kamikaze28)
Description
Requires Mac OS X 10.6 Snow Leopard
These services will appear in every contextual menu of files. You are now just 2 clicks away from posting something to Dropbox!
Usage Instructions
INSTALLATION
- Drag 'Move to Dropbox.workflow' and/or 'Copy to Dropbox.workflow' to
~/Library/Services/
dropboxID = '<DROPBOX-ID>'
http://dl.dropbox.com/u/7925/Post%20to%20Dropbox.zip
Note: The script is designed to work with your Dropbox in the default location. If your Dropbox resides in a different place, consult the attached readme for instructions on how to change the script to work properly.
USAGE
- Right-click on a file or folder (in Finder, Mail, ...) and select 'Move/Copy to Dropbox' from the contextual menu. Files will be put into your Dropbox public folder, auto-synched and the URLs to these files will be put in the clipboard. In the case of folders, there will be URLs to all the files it containes in the clipboard. Files of the same name will not be replaced. If you want to change this, you can edit the 'Move/Copy Finder items'-block in the workflow (there is a checkmark to enable 'overwrite existing files').
SOURCE CODE
- Here is the Python script, that converts files and folders into the public links.
import os, sys, urllib
# Enter your Dropbox ID here. If a public link form you looks like
# http://dl.getdropbox.com/u/7925/Post%20to%20Dropbox.zip
# your Dropbox-ID is 7925 and this line has too look like this:
# dropbox_id = '7925'
dropbox_id = '<DROPBOX-ID>'
copied_files = []
for arg in sys.argv[1:]: #for all input arguments
if os.path.isdir(arg): # if it is a directory
for root, dirs, files in os.walk(arg) : #traverse it
for file in files: #and for every file
if not file.startswith("."): #if it isn't a hidden file
current_file = os.path.join(root, file) # compose the path
copied_files.append(current_file) # and add it to our list
if os.path.isfile(arg): # if it is a file
if not arg.startswith("."): #if it isn't a hidden file
copied_files.append(arg) # just append it to the list
pasteURLs = [];
for file in copied_files: # for all elements in our list
components = file.split(os.sep) # seperate the path
local_dir = os.sep.join(components[5:]) # cut off the beginning
local_dir = urllib.quote(local_dir) # convert it to a URL (' ' -> '%20', etc.)
#construct the URL
finalURL = 'http://dl.dropbox.com/u/%s/%s' % ( dropbox_id, local_dir )
pasteURLs.append(finalURL) # add the current URL to the string
copy_string = "\n".join(pasteURLs)
os.system( "echo '%s' | pbcopy" % (copy_string) ) # put the string into clipboard
Links
Download http://dl.dropbox.com/u/7925/Post%20to%20Dropbox.zip
