Judging from some of the comments that I’ve been reading on the Evernote forum, HTML export can’t get here soon enough! And even though I’m pretty sure it’ll be officially released soon, there has to be a way that we can get the job done now, right?
Well everyone — Native HTML Export is now here! I’m leaving this page up in case:
- The code is helpful to someone, or
- People are interested in me adapting this into a “Bulk Webarchiver” (e.g., taking a bunch of Evernote items and saving them into self-contained “.webarchive” files
If you’re interested in that, leave a comment on this page! Otherwise, Evernote’s built-in exporter will probably do the trick for you….
And now….the original project below!
The Big Picture (With Details)
I’ve designed a script that looks into the current application directory for Evernote, copies the HTML file and constituent elements, puts it in a folder named after the note, and then bundles everything up into a single Web archive file.
(Pretty cool, huh?)
This isn’t designed to replace the forthcoming “Export to HTML” feature; I wrote it in order to facilitate some of the other scripts that I’ve been working on for my clients (keep your eyes peeled for those!).
However, I realized that it would provide a stop-gap solution until the export HTML feature is activated and so I am releasing it to the community in case someone finds it helpful! When Evernote adds HTML Export into the program, use it!
That said — this script works really well for me! “Web Archiving” (a.k.a., everything into one file) was the feature that I was most excited about and so, following some sort of Murphy’s Law of AppleScript Coding, it also ended up being the thing that took me the longest to get working properly.
This script differs from my previous releases in that it also bundles a file known as “webarchiver” into the script file itself. Without it, the script doesn’t work — something to keep in mind if you are trying to cut and paste the source code into the script editor.
What is “webarchiver”?
Webarchiver is a program that allows you to use Safari’s “Save As Web Archive” command from the command line in Terminal (or, in our case, from a “do shell script” command inside of AppleScript). Paul William from Entropy, The Blog, webarchiver’s creator, was incredibly gracious in assisting me with the implementation of it into the AppleScript. With his help, everything finally worked! Moreover, webarchiver itself is a wonderful, useful program and, without it, this project would not have turned out as well as it did. Thanks Paul!
- This script copies the selected Evernote items and saves them in 2 HTML formats: It consolidates all of the elements into a “Web Archive” so that everything is contained in one file, and it also creates a Folder named after the note containing all of the “non-Evernote” elements (e.g., everything except the recognizer and ENML files). For the purposes of this script, I figured it would be better to let people have the choice of *how* they wanted their data — thus the Folder/Web Archive output;
- The script lets you select where you’d like to export your files. I had to use shell scripting to clean up some file name weirdness that was causing the script to fail. As a result, you’ll see that typographical characters are sometimes removed from the original file name. Don’t let it freak you out.
- Automatic Growl detection has also been enabled which will save you a trip to the Script Editor to enable/disable it.
Current Limitations and Open Issues
(Otherwise known as “Places Where You Could Help Out!”)
- The file names are sometimes altered in the exported version if they include typographical characters that would halt the file creation process;
- The script is looking to the current folder structure for the files to copy. When Evernote updates the database structure, the script will probably stop working until I update it. Then again, my guess is that they’ll have a working “Export HTML” feature when that happens…which will probably eliminate the need for this script in the first place!
- Errors that will undoubtedly arise when you do something that I didn’t think of (or test for)! 😉
How to Install and Use
Just run the script, highlight the notes you want to export from Evernote, and tell the script where you’d like the files saved!
- You can highlight multiple notes;
- You can save this script to /Library/Scripts/ and launch it using the system-wide script menu from the Mac OS X menu bar (The script menu can be activated using the AppleScript Utility application). Keyboard shortcuts can also be assigned to AppleScripts in the script menu using the System Preferences “Keyboard & Mouse Settings”.
FastScript link and support
Do yourself a favor and download and install FastScripts from Red Sweater. Triggering the script from the keyboard really makes things almost second-nature: you’ll watch items practically fly into and out of Evernote with a few keystrokes!
Here’s how you set it up:
- Copy script or an Alias to ~/Library/Scripts/Applications/Evernote
- Set up your keyboard shortcut in the FastScripts Preference menu
For my FastScripts workflow, I am using ⌘ H (as in HTML).