This is a crosspost from The Cat Convention.
If you’re not familiar with Dropbox by now, you should be. Dropbox is what MobileMe‘s iDisk aspires to be one day. For now, it isn’t.
For the uninitiated, Dropbox is a fantastic cross-platform bit of code that synchronizes files across all of your computers. It also provides a look into the folders via a web browser if you should need it. They also offer an iPad app that allows you to browse and download files to local applications such as Pages.
Alas, Pages on the iPad, however, doesn’t speak Dropbox. It will allow you to edit the documents and export them to:
- An email
- iWork.com
- iDisk
- A webdav server
Dropbox is missing from that list. You could save your files back to your iDisk, but then you’d need to go to a regular machine and copy that file from the iDisk to your Dropbox folder. That’s pretty obtuse.
While we wait for Apple to purchase Dropbox and implement it as an iDisk replacement, we can use the magic of Apple Mail and Applescript to create a nifty workaround. Today I spent some time on a script that will do the following:
- Take the contents of an email message with a particular subject line
- Extract the attachment
- Save the attachment in a Dropbox folder depending on the keyword you use in the subject line of the message
Since Dropbox runs all the time on your Mac, it will notice the file change event and automatically sync the file to all of your computers linked to that Dropbox account.
Making an Applescript that will save an attachment to your file system is quite easy. Linking a mail rule to that Applescript is also quite easy. Therefore, the implementation of this is easy. What makes this script a little different is that you can specify keywords in the subject line and it will decide where to put the file inside your Dropbox folder based on the keyword. Editing those keywords are completely up to you.
To implement, download the “Save Attachment to Dropbox.scpt” file below. You should open /Utilities/Applescript Editor.app and modify the script’s keywords for the subject lines you plan to use. Save the .scpt file to your favorite location for AppleScripts. (For Mail scripts, I use “~/Library/Scripts/Mail”).
Next, create a rule in your Apple Mail using criteria to judge when to fire off the rule. In my case, I told it to look for messages that meet all of these criteria:
- Messages coming from a particular email address
- Containing a subject line keyword that starts with“-savedb”
The script will execute and look at the subject line of your email message. The subject line should start with “-savedb…” and have some kind of keyword in there. You edited the script to define those, right? Well, you don’t use the rule to define those keywords. Note that I said in the keyword to use “starts with” the string “-savedb”. The script will determine what to do with it based on what you code there.
I also recommend adding an action to move the processed messages over to a folder. In my case, I created a folder called “Processed to Dropbox” and told the rule to move the message there.
An important note: the script will overwrite any files that have the same name as the file. I felt that this was a safe thing to do since Dropbox automatically backs up 30 copies of the file on the site and you can retrieve any version you like. Deleted versions of the files are tossed in the Trash. They are not deleted completely until you empty the Trash. If you still do not like this behavior, feel free to modify the script to remove that action.
Now all you have to do is send yourself an email from the proper address with the proper keyword from your favorite app on the iPad and voila, it’s instantly synced to all of your computers and backed up.
Another way to use this is via “DropDAV” at http://dropdav.com. I was close to using that solution until I read more about it. I decided I wasn’t entirely comfortable with giving another third party my Dropbox username and password, so I developed this method instead.
If you want to encourage the developers of Dropbox to add WebDAV support, be sure to give them a +1 vote here.
I hope you enjoy this script and it helps band-aid the interruption in workflow until Apple purchases Dropbox. 🙂 If you have any questions, don’t hesitate to ask in the comments below.