Dropbox in Snow Leopard (part deux)
You can do a lot of neat little things with the new automator services-template. In my last post I wrote about making a litle automation to replace a feature that wasn’t in dropbox in Snow Leopard, but you can go further. Why not make the service copy any selected file over to the dropbox public folder and then copy the public URL to the clipboard.
It’s basically the same automation as in part one, but the applescript does more:
(UPDATED)
1. Open up automator again and choose the services template.
2. At “Service receives selected” choose “all files and folders” in “all programs” (you can choose the finder too, but i don’t see why “all programs” would be an issue).
3. The workflow goes: –> execute applescript –> copy to clipboard
4. In the applescript section you write:
<(*Created by Robin Ramael on 29th of august 2009
Under Creative Commons License Attribution-NonCommercial (http://creativecommons.org/licenses/by-nc/3.0/)
FILL IN YOUR DROPBOX USER ID BELOW!!!!
*)
on run {input, parameters}
(*FILL IN YOUR DROPBOX USER ID HERE*)
set userid to 244025
(*FILL IN MAXIMUM FILESIZE (in mb) HERE*)
set maximumfilesize to 50
set dropboxpath to (path to home folder) & "Dropbox:Public:" as string
(*Check if filesize isn't too big*)
get size of (info for input)
set filesize to result / 1000000
if filesize is greater than maximumfilesize then
say "woaw"
display dialog "This file is larger than 50 mb, are you sure you want to upload it to Dropbox?" with icon caution
end if
(*Copy file*)
tell application "Finder"
duplicate input to folder dropboxpath with replacing
end tell
(*Get the name of the file to put in clipboard later in the automation*)
tell application "Finder"
get name of (info for input)
set filename to result
set dURL to "http://dl.getdropbox.com/u/" & userid & "/" & filename as string
end tell
return dURL
end run
(Replace the ‘xxxxxx’by your dropbox user id. Remember, you can get this ID by going to any of your public files in the browser and looking at the URL. For example, if you have the URL “http://dl.getdropbox.com/u/123456/file.txt”, 123456 is your user ID.
You also might have to replace the “smart quotes” with normal quotes, i’d put in
tags but there is no support for them with applescript…)
5. Save as “Copy to Public Dropbox and copy URL” and we’re done! You can now go to any file , right-click it and click ”Copy to Public Dropbox and copy URL” or whatever you named it and voila, the file is copied to your dropbox and the URL is copied to your clipboard.
The applescript also checks if the filesize isn’t too big (default is larger than 50 mb, but you can change that) to make sure you don’t accidentally start uploading a 4 GB file to you tiny, tiny dropbox.
UPDATE: This currently only works with some filenames. Filenames with spaces or presumably backslasher are ‘not yet supported.’I’ll have to poke myself for version 1.01.
[...] October 9, 2009 A few weeks ago I posted an applescript that could be used in an automator-service to automativally upload a file to your public dropbox and copy the URL to your clipboard. You can find that post here) [...]
Thanks for this, it’s really good. However, I ran into a couple of snags getting it to work.
First up, when you’ve copied the code into wordpress it’s changed all of your quotes into “smart quotes”. So before the script will run people will have to do a find + replace (watch out for the single quote marks following the sed command, they need changing as well.
Also, your comments were originally proceeded by two hyphens but wordpress has changed them as well.
Could I suggest that before you copy code into wordpress you try something like
.
Finally, the original automation instructions are missing the final instruction, to include the “copy to clipboard” Action onto the end of the workflow. Anyway, thanks for the script, it was just what I was looking for.
Cheers
bah, i wasn’t expecting wordpress to format my code
I’m talking about the square bracket sourcecode language = html thing mentioned here
http://en.support.wordpress.com/code/
under “posting sourcecode”
ciao
Thanks, i hadn’t noticed. unfortunately there’s no support for applescript so i changed the comment-syntax and warned for the smart quotes. Is there some kind of raw text tag? I couldn’t find anything ot that…
oh, you did warn about the smarkquotes. Sorry, I should’ve read your instructions more carefully. My bad.
When i posted an applescript about a year ago I set the code to language=’html’which didn’t colour it but preserved its usability:
http://monototo.wordpress.com/2008/09/02/iphone-re-geotagging/