Evernote Export to RTF Applescript

ev-rtf-scriv

I read a post on the Evernote forum the other day from a writer who wanted to use notes from Evernote in Scrivener, a word processing/research program designed specifically for authors/screenwriters. It’s a fantastic program — the kind that really opens people’s eyes to quality of Mac applications — but it isn’t scriptable. Head Scrivener Guru Keith said in a post on his own forum this past December “Just for the record, it’s highly unlikely that Scrivener will be getting AppleScript support any time soon. It’s a big job and low down on the list – certainly it won’t be making 1.5. It is still slated for a distant future release, though!”

And though HTML export is planned for a future version of Evernote (and, perhaps, even sooner than that….), there has to be a way we can help this guy out…you know….NOW!

Now that Evernote has released native HTML export, there’s two ways to help this guy out:

  1. Have him export his files to HTML directly from Evernote (which he can then import into Scrivener’s “Research” folder and refer to as a reference), or
  2. If he needs to edit the notes inside of Scrivener, the answer is this AppleScript —  It converts notes from Evernote into Rich Text Format with Attachments (RTFD files)!  He can then import them in to Scrivener (or any other program that accepts RTF files) and edit away!

Don’t you just love AppleScript?

Features — Updated October 17, 2010

  • This script exports a rich text copy of selected Evernote items and saves them in RTFD format. It also leaves an HTML copy of the note (and its resources) inside a sub-folder named after the note (in case you find it useful!)
  • Automatic Growl detection has also been enabled which will save you a trip to the Script Editor to enable/disable it.
  • ev-rtf-growl

Current Limitations and Open Issues

(Otherwise known as “Places Where You Could Help Out!”)

  1. The RTFD conversion works with most notes, but not with PDFs! The script exports any available text information to the RTFD file and places attached files in a resource folder by the same name at your export location.
  2. Notes with typographic symbols in the title will sometimes halt the conversion (see an example in the picture below).  I’ve done some work on having the script automatically eliminate the offending characters but, if you still have problems with a particular note, just edit the symbols out of the title and you should be fine!
  3. Errors that will undoubtedly arise when you do something that I didn’t think of or test for! 😉

How to Install and Use

Just highlight the notes you want to export in Evernote and then run the script (you can highlight multiple notes). Tell the script where you’d like the files saved and it will go to work!

  1. You can highlight multiple notes;
  2. 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 ⌘ R (as in RTF).

Change Log:

  • 1.30 (OCTOBER 17, 2010) UPDATED TO UTILIZE EVERNOTE API FOR SELECTION
  • 1.20 (JULY 17, 2009) UPDATED TO FIX A COSMETIC ISSUE, CHANGE PATH FOR RTFD FILES
  • 1.10 (MAY 29, 2009) UPDATED TO USE NATIVE HTML EXPORT, CREATE RTFD FILES
  • 1.00 (MAY 12, 2009) INITIAL RELEASE OF SCRIPT

Click Here To Get The Latest Version of The Script!

Did this script help you out? Feel free to make a donation!


Found a bug in the script?

Click Here To Submit Your Bug Report!

Interested in what other scripts are available for Evernote?

Click here to see the latest list!

28 Responses to “Evernote Export to RTF Applescript”

  1. emoreth May 21, 2009 at 4:55 am #

    Exactly what I was looking for!

    The only other thing that would be nice is the ability to export an RTFD file so embedded images don’t go away. How hard would it be to make a script that can do that? (I’d try to figure it out myself, but I know no AppleScript whatsoever.)

    • Justin May 21, 2009 at 4:34 pm #

      Glad it was helpful!

      To answer your question — YES, it’s possible and you should check back (or subscribe to the RSS feed) because I will release it in the near future.

      A couple of quick questions for you:
      1.) How are you using these exported files? (i.e., Are you importing them into a program like Scrivener? Just saving to your HD for archival purposes? Emailing them to non-Evernote users?)

      2.) Are there any other applications that you’d like to use your Evernote data with?

      Kind Regards,

      Justin

      • Michael May 31, 2009 at 3:43 pm #

        Justin, I’m sorry, but I’m confused. (I’m a writer, not a techie.) I don’t really understand what AppleScript can do, but I think I understand that you created a two-step process for getting Evernote notes into Scrivener, which I very much appreciate. However, I don’t know how to employ it and think at least part of what you did was outdated by Evernote’s latest release for Mac. (I infer that from your post above.) When I exported Evernote notes in HTML and imported the HTML into Scrivener, I got several identical folder names in my Research section, each leading to a different folder that held the content for separate notes. Does your script cure that? Thanks, and sorry to be such a dunce. MP

        • Justin May 31, 2009 at 7:54 pm #

          No problem, Michael — we’ll get you to that elusive “Eureka!” moment yet!!! 😉

          To answer you second question first, “YES, the script will “cure” the folders in the Research area”. Here’s why:

          When importing a file in RTF format, Scrivener allows you to edit the text, not just look at it as with HTML imports. As such, it puts the imported files with your other Draft items — not in the research section.

          I’m going to take a guess and assume that you don’t know how to run the script…(forgive me if this is “too basic”, but I’m not sure if you’ve ever run a script before).

          Download the script from the link on Page 2 of this post and open it on your computer. It will probably open a program called “Script Editor” and you’ll see the text of the script in the window. Press the button at the top that says “Run” and just follow the instructions from there. It will export the files you select and save them in a folder of your choosing. From there, you can import them the same way as you did for the HTML notes. Remember- look for your imported notes with your DRAFTS, not in the research section!

          One you’ve got it working, I’d really recommend downloading the free FastScripts program: It makes it easy for new AppleScript users to launch scripts with a simple keyboard shortcut (eliminating the need to open and manually run the script each time).

          Let me know how far this gets you and we’ll take it from there!

          Kind Regards,

          Justin

          • Michael July 2, 2009 at 3:21 pm #

            Justin,
            You probably thought I just walked off and forgot. Not at all! I’ve had my share of hardware problems of late and am actively engaged in research as well, so I put off the Evernote/Scrivener problem just long enough to forget where I’d found you. I knew I jumped from one of the forums to a separate site but thought I’d started at Scrivener. So now I’ve found you again, have a lot more Evernote notes to import and have downloaded your script. The FastScript item on Red-Feather appears to be down at the moment. In any case, I’m going to follow your instructions and see what I get into Scrivener. I understand to look in Draft instead of Research and will do that. However, just FYI, that confuses and adds a step because I’ve got all my chapters and chapter summaries in Draft and all my notes, transcripts, etc. in Research. If there’s a way to choose the destination, I would do that. Have a great Fourth, and I’ll let you know how I do. MP

          • Michael July 6, 2009 at 10:25 am #

            Justin, some progress to report. I installed your script and FastScripts from Red-Sweater and, after some confusion, managed to set up Command-E as my hot key to your script. Now, when I’m in Evernote, I can hit Command-E and bring up all the notes from a notebook and select the ones I want to export. Two problems: Once, when I selected multiple files, nothing happened, and I couldn’t find any of the supposedly exported files. Trying with just one or two files selected, I got a window asking where to put the exported files, and I sent them to …/Evernote Exports. When I checked, each file was in a new subfolder of its own, both as an html file (with still another subfolder) and as the .rtfd file I wanted. However, they don’t show up in Scrivener until I import them, and to do that, I have to go to each subfolder, find the .rtfd file and select it. That seems to destroy all the efficiency I got from your script converter. Am I doing something wrong? Thanks. MP

  2. Justin July 6, 2009 at 12:39 pm #

    Hi Michael — Glad to see that you’re making progress!

    The script is working as designed, so you’re not doing anything wrong… here are a few things to keep in mind:

    1.) Scrivener doesn’t have AppleScript Support. The reason you have to manually import the files is that Scrivener lacks the AppleScript-ability to fully automate the import! There’s no way around doing it manually unless Scrivener adds AppleScript in a future iteration;

    2.) The purpose of the script is to convert notes to RTFD-formatted files. Because of item number 1 above, this isn’t a “Scrivener Script”, but rather a more generic RTF conversion script. I wrote this because Evernote currently lacks a built-in RTF exporter — although it sounds like they are going to include it in an update soon. Until that happens, however, this script should work fine!

    3.) Drafts/Research, Sub-folders, and HTML files. The reason that RTF-imported files appear in Drafts is because they are editable. If you want non-editable notes to appear in Research, you really don’t need this script: Just export HTML files from Evernote and, when you open them up in Scrivener, they will be placed in the Research section. Part of my script’s conversion process is to have Evernote export HTML files so that they can be converted into RTFD files — both are left in the subfolder for use in any way that “makes sense” to a user, given their particular needs.

    4.) Fast Scripts Trigger In the example above, I am using Command+R so as to distinguish it from my other scripts. Make sure your shortcuts are set up correctly and that you are running the right script at the right time.

    5.) Multiple Item Selection It’s working fine here… can you give me more detail about when it works and when it doesn’t? (e.g., Are any of the note names the same? How many notes are you trying to export at one time? etc.)

    Hope this helps!

    Justin

    • Michael July 7, 2009 at 6:44 pm #

      Justin, thanks for your reply. More progress. I don’t know what the problem was with Multiple Item Selection (5 above), but it seems to be working fine now. Maybe there was a filename it didn’t like or something.
      2.) Here’s the issue: When I am in Evernote and trigger FastScripts to run your script, I get a choice of notebooks, then all the notes in the notebook I select. Then, when I select one or more notes, I select the folder to send them to, and off they go. But when I go into Scrivener to import the .rtfd files that your script created, I go to the folder I selected in Evernote, but instead of the .rtfd files and .html files, I see a bunch of new subfolders, one for each exported note. Why does the script create those new subfolders? It seems to me it just slows down the import process. Is there a way to choose to dump all the .rtfd and .html files into one export folder? Thanks. I really appreciate your taking the time not only to write the script but to help people like me use it.

  3. Jochen Witte July 7, 2009 at 4:14 pm #

    Justin, I just tried to install you script, since it exactly what I’m looking for: most of the documents I write are RTF and I would love to be able to easily integrate notes I took on my mobile into my workflow.

    However, when I tried to install the script, I always get an error, regardless, if I run it directly in the Script Editor or from the scripts menu:

    07.07.09 21:51:18 Quicksilver[435] Run Script: System Events got an error: AppleEvent timed out.

    Any suggestions?

    • Justin July 7, 2009 at 4:33 pm #

      Hi Jochen,

      Are you using Quicksilver to launch? How long does it take before you receive the error?

      The only time that I’ve personally seen the “timed out” error was when the window that lets you select the notebook/notes didn’t appear in front and I forgot that the process was running….

      Try this:

      1.) Run the Script from the Script Editor
      2.) If you don’t see the “Select Evernote Notebook” window, look in the dock for any bouncing icons…if you don’t see anything bouncing, try to select the Evernote icon manually.

      Let me know if this solves/doesn’t solve your problem and we’ll take it from there!

  4. Justin July 17, 2009 at 4:02 pm #

    I’ve just updated the script to save the RTFD files in the main save location while putting the HTML/resource files in named subfolders. To me, it seems like the “middle way” between just dumping everything in one folder and the way the script worked before.

    Evernote will likely release a built-in version of RTF export in the near future. When they do, I will re-examine this script to see if it is still useful and, if it is, further revisions will probably utilize the native export (assuming that Evernote makes it AppleScript-able).

    Keep your suggestions and comments coming!

  5. Michael July 20, 2009 at 12:11 pm #

    Justin, thanks for the change, but I don’t seem to be able to get it to work. I downloaded the new version, 1.2, and sent the earlier version to the trash. However, when I use Fastscripts to call up your script, it runs just like before–and creates the same subfolders and drops the rtf and html files into them. Could there be a previous version lurking somewhere and executing instead of v1.2? I found two of the old ones with Spotlight and ditched both. Thanks, I appreciate your work on this. It really helps. MP

    • Justin July 20, 2009 at 12:29 pm #

      Hi Michael — THANKS FOR THE DONATION!

      My guess is that you need to update the keyboard shortcut in FastScripts to point to the new script (the one that ends in 1.2).

      Click on the FastScripts menulet (looks like a slightly fatter AppleScript icon), then select FastScripts=>Preferences. The preferences pane will open and you can update the shortcut on the “script shortcuts” page. It’s also not a bad idea to make sure you’ve emptied your trash when tossing out old scripts/apps/etc.

      Let me know if this does the trick for you!

  6. Michael July 20, 2009 at 1:19 pm #

    It’s working! Many thanks.

  7. Peter Norman August 24, 2010 at 6:27 pm #

    Hi!

    Thanks for the great scripts!

    The Evernote to RTF export script results in a black background in the RTF file for some reason.

    I’m using:
    – Mac OS X 10.6.4
    – Evernote 1.10.1 (93489)
    – DevonThink Pro Office 2.0.3

    I hope that helps!
    Peter

    • Justin Lancy August 24, 2010 at 6:35 pm #

      Hi Peter!

      Are you by chance using Safari 5 on your Mac? If so, make sure you have the latest updates to it and try the script again. There is a known “black background issue” which is solved for many people by downloading installing it.

      In either event, please let me know if this helps!

      • Peter Norman August 24, 2010 at 6:54 pm #

        Sorry, Justin – I forgot to mention in my original post that I’m using Safari 5.01. I’d heard of the “black background issue” and the Safari 5.01 fix and wanted to give you all the details in my first post! D’oh!!

        Thanks very much for the super-quick response!

        -peter

        • Peter Norman August 24, 2010 at 7:48 pm #

          I just found a discussion thread on Apple’s forums that talks about a possible bug (separate from the one fixed by Safari 5.01) that may impact this black background issue in the Evernote To RTF Export script:

          Here is the link in case it might help your troubleshooting:
          http://discussions.apple.com/thread.jspa?messageID=12027623

          Thanks again!
          -peter

          • Justin Lancy August 24, 2010 at 9:41 pm #

            Hi Peter,

            That link was very helpful!

            While it looks likely that we’ll have to wait for the mentioned Apple bug fix to be released, there may be a way to write the background color into the converted file with some Script-fu… I am planning on an update to this script very soon anyways, so I’ll take a swing at it when I do.

            Who knows — maybe we’ll get lucky! 😉

            And should you come across any additional information in the interim, please come back here and share it with us!

          • OogieM December 4, 2010 at 8:01 pm #

            Any info on a possible solution to the black background problem yet.

          • Justin Lancy December 4, 2010 at 8:07 pm #

            As of version 10.6.5, things are fine for me…

            Give it a shot and let us know your experience!

  8. OogieM December 4, 2010 at 8:49 pm #

    I’m on 10.5.8 and can’t upgrade at this time :sigh:

    ANy ideas on a workaround?

    • Justin Lancy December 6, 2010 at 4:15 am #

      I’ll keep my eyes open for something….

  9. Ralph January 8, 2011 at 12:54 am #

    Awesome script! Thanks for writing and supporting this
    invaluable tool. Didnt notice this in the comments – is it possible
    to preserve TAGS on exported notes? What about the Date Created?
    Thanks, Ralph S.

    • Justin Lancy January 8, 2011 at 3:48 am #

      Thanks Ralph!

      Question: How would you like to see that work? Where would the tags/date created go?

      • Ralph January 11, 2011 at 4:37 pm #

        Justin –

        In thinking about this, the most useful output would be if each RTF file’s Date Modified reflected what is shown for that Note in Evernote.

        Tags (and maybe also Date Created) should be written to the file metadata in the same way that programs such as Notational Velocity (mac) and ResophNotes (win) sync tags with SimpleNote.

        Another option would be the tags could all be listed in the first or last line of the note itself, separated by spaces, so they could be searched

        Hope that make sense.

        Ralph

        • Justin Lancy January 12, 2011 at 10:14 pm #

          Hi Ralph!

          It may be possible any of these… but the first two are a little complicated from a scripting point-of-view: I’ve been messing around with using OpenMeta (e.g., tags written to file metadata)… and trying to pull that off using only standard AppleScript — so far with mixed results. I’m still working on it!

          The Date Modified may not be achievable, but I think the Date Creation may well be.

          Adding the into directly to the file is much easier! If enough people ask, I’ll take some time and add it in!