I use dropbox a lot to share files and a recurring task is to copy a file into the dropbox public folder, create a link and email it off. Additionally, I like using Merlin Mann’s trick of zipping a file, renaming it to something obscure and sending that link. Recently, I found Brian Hayes’s trick (via Macsparky) to streamline the process using Textexpander.
I wanted to adopt it to my workflow and created an automator service that I can run in the finder, with a file selected. It does the following:
- zip the file
- rename the zip to something obscure, using Brian’s code
- move the zip to the dropbox public folder
- create a link to that file, using this code from Chez Moncef, the dropbox forum and stackoverflow
- create a new email in mail.app and put the link into the body
To use this service for your needs, you need to edit two values:
- your unique dropbox id number, which you can get by creating a dropbox link of any file in your public folder and
- the path of your local dropbox folder.
You can save the service and access it in the finder by right-clicking on any file. I combine this with a Hazel rule that cleans out my public folder after a certain time. If you use this a lot you could set up a keyboard shortcut for the service in the keyboard preference pane.
Here is what the automator service looks like:
And here is the applescript:
on run {input, parameters} set str to {} set end of str to some item of "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz" repeat 12 times set end of str to some item of "ABCDEFGHIJKLMNOPQRSTUVWXYZa;rndbcdefghijklmnopqrstuvwxyz1234567890`~!@#$%^&*()_+-=[]>?;:'" end repeat set randString to str as string tell application "Finder" set theFile to file input set theNewName to (randString & ".zip") set the name of file input to theNewName (*Change the dropbox path if necessary*) set dest_folder to folder "Documents:Dropbox:Public" of home move file input to dest_folder end tell (*Change YOUR_DROPBOX_ID to your unique dropbox id*) set the theURL to ("http://dl.dropbox.com/u/YOUR_DROPBOX_ID/" & my text2url(theNewName)) set the clipboard to theURL as text tell application "Mail" activate make new outgoing message with properties {content:the clipboard, visible:true} end tell return input end run on text2url(thetext) return do shell script "python -c \"import urllib, sys; print (urllib.quote(sys.argv[1]))\" " & quoted form of thetext end text2url
I get an error.
Run Applescript failed – 1 error
Can’t make {} into type integer
I get a zip, but it it wont move to the Public Folder
Do you know on what line you get that error?
nope
how I can be the only one, who get’s this error?
Sebastian…
Are you pointing the script to the location of the Dropbox Public folder on your local hard drive? The one in this post assumes Dropbox is located at ~/Documents/Dropbox/Public. My Dropbox Public folder installed several years ago is at ~/Dropbox/Public. If you have my set up, you need to remove Documents: before the word “Dropbox” in the line that sets the path.
One other thought, the script wouldn’t work for me when I tried to point it to a subfolder I had created in my Dropbox Public folder. Don’t know why exactly unless the Dropbox ID one gets only works for the Public folder itself. So, again, make sure you are pointed squarely at your PUblic folder and see what happens.
I point to ~/Dropbox/Public
I get this error message in Automator http://cl.ly/1y2U1d182z2s1s0W0k0b
now it works…
I changed Dropbox:Public to Dropbox/Public
btw great work! 😉
Sebastian: Cool! I’m glad it works for you now. I’m not really sure why it had to be changed to Dropbox/Public instead of Dropbox:Public, though.
thelamike: Thanks for following up.
now it doesn’t work anymore… wtf?
Sebastian,
can you post your error ? Do you still get a warning for the “create Archive” action?
I’ve reproduced your error. It only happens when you try to run the service from within automator, which you wouldn’t normally want to do. The service works as is. You activate it by right-clicking on any file in the finder -> services -> the name of the service.
When you run it from within Automator it doesn’t get an input file and both the archive and the applescript don’t work. If you ever want to test your services from within automator you need to add the action “get selected Finder items”, which will use the finder items you selected, or “get specified Finder items”, which uses a certain file whose path you specify.
This is quite elegant. You’ve built on a great idea hatched, I believe by Eddie Smith of Simplicity is Bliss fame, and enhanced by the guru Merlin Mann for emailing sensitive data. This Service works like a charm and when coupled with Merlin’s suggestion, picked up by you, of protecting things via a Hazel sweep rule, you’ve produced a no brainer way to send sensitive stuff via email as safely as possible. Thanks for this share!
Thanks! Yes, I just put all the great ideas of Merlin and others together to fit my workflow.
Pingback: Share a bunch of files quickly and securely with Dropbox using Keyboard Maestro | Kaush's Journal
neat stuff! always refreshing to see alternate more efficient ways of doing the same old things. inspired by your automator script, i’ve written a keyboard maestro variant that does something similar : http://journal.kaush.co/553/share-securely-with-dropbox-keyboard-maestro-finde
Cheers.
Very cool! Thanks for this.
Thanks for this, me too!
Hey! Do you use Twitter? I’d like to follow you if that would be okay. I’m absolutely
enjoying your blog and look forward to new posts.
I don’t currently use twitter, but will update my contact info when I do. I’m glad you’re enjoying it.
This is a great script. I am new at scripting so can you pleas post a script that does all the above but that does NOT change the file name to a random string and rather keeps the name of the original file?
Thank you,
Alexis
Never mind, I managed to figure it out for myself. Thank you anyway!
I couldn’t find my Dropbox ID in a link of any sort which I tried to create from files & folders within my dropbox account – anyhow I just copied the entire link to my public folder and pasted that into your code replacing “http://dl.dropbox.com/u/YOUR_DROPBOX_ID/” – it even works when i right click a file in another folder – creates a zipped file and places that in the Public folder and you can share that.
Thanks