Use Mac OS X Services to Import Files into Evernote

September 23, 2009

During my recent foray into rediscovering Evernote, I experimented with Evernote’s Applescript dictionary and Snow Leopard’s updated Services architecture.  My goal was to write a service that made capturing data into Evernote even easier.

I was pretty excited to see how easy it was to write a service and created one that directly import files from the Finder into Evernote.

Here’s how to set it up:

1) Launch Automator and select “Service”

The Service template in Automator is new to Snow Leopard and lets you create services from scratch.

Select Automator Template

2) Change “Service receives selected” to “files and folders”.  Leave “any application” selected and “replaces selected text” unchecked.

The new Services template can handle a number of data types, but for us files or folders is what we want.

Receive Selected Files or Folders with Automator Service

3) Pick the “Run Applescript” action from the Utilities Library and copy and paste the below applescript into the input box.

This script has error handling built in (that’s the try… end try statement), so if you pass something that Evernote can’t handle, you will get an alert box telling you what is wrong.  The most common error you may see is if you try to pass the service an unsupported file type.  For example, if you are not an Evernote Premium user and try to pass it a Word doc you will get an error, or if you try to pass it a folder, you will get an error.

The script supports passing multiple files (and if one of the files creates an error condition it will only fail that import, not the entire batch).

on run {input}
     tell application "Evernote"
          repeat with x in input
               try
                    create note from file x
               on error error_message number error_number
                    display alert "Send to Evernote Failed" message "Error:     " & error_message & "
" & "Error Number:  " & error_number as warning
               end try
          end repeat
     end tell
end run

When you are done in Automator, it will look like this:

Import To Evernote Service

That’s it!

4) Go to File > Save As and name the service “File | Import to Evernote”

This saves the service so it is available throughout OS X.

5) Set a Keyboard Shorcut via Automator > Services > Services Preferences

This is not required, but if you want to create a keyboard shortcut, just find the “File | Import to Evernote” Service and double-click the keyboard shortcut column.  I assigned shift-command-E, but you can do whatever makes sense for you.

Assign Evernote Service Keyboard Shorcut

6) Try it out!

Now when you are in the Finder, you can click your keyboard shortcut and/or right click and pick the service from the context-menu and import files direct into Evernote.

Evernote File Service in Context Menu

Last Tip:  If you have Growl installed and have it configured for Evernote, you will get a Growl notification once the import is successful.  It puts a nice finishing touch to the service.

Growl Notification of Evernote Import

  • Andrew McGeachie

    Cool, thanks for posting this.

  • http://veritrope.com Justin

    Ken, Both the concept and your walk-through are fantastic – Nice work!

    Justin

  • Ken Clark

    Andrew–

    Thanks for all the great work on the Mac app. Evernote really rocks. –Ken

  • Ken Clark

    Justin, thanks! I am really enjoying both Evernote and Services. It was a nice way to link the two together.

  • http://macpowerusers.com/?p=155 Mac Power Users» Blog Archive » MPU 011: Services and Macworld 2010

    [...] Applescript Snow Leopard Services Applescript 1-2-3 MacBreak Video Services Episode Listener Ken’s Post on Evernote Service David’s Post on Title Caps Service Macworld Expo and Conference 2010 David’s “Mac [...]

  • http://veritrope.com/tips/evernote-applescript-resources-and-accessories Links to Evernote Applescripts and Accessories– Updated Regularly! | Veritrope

    [...] lift­ing — slower, but brings over mul­ti­ple items)Other Scripts/Extensions/ProjectsNEW Using Snow Leop­ard Ser­vices to import files from FInder into Ever­note. Great walk-thro…NEW Livescribe/Evernote AppleScriptNEW Import Ama­zon Kin­dle clip­pings into [...]

  • Martyn

    Excellent tutorial. Works like a treat. Many thanks for your time & effort.

  • Adrian

    This is cool but is it really any easier than dragging the file to the evernote icon in the dock??

  • Stan Scott

    Utility works like a charm. Thank you!!

  • Ken Clark

    Adrian–

    Two scenarios where I believe it is easier: 1) The service allows you to import to Evernote using keyboard shortcuts. 2) If you auto-hide the dock (I do), dragging becomes a time-consuming process.

    Thanks for reading,

    Ken

  • Ken Clark

    Thanks Stan. Glad it worked for ya!

  • http://www.heynanynany.com trav

    this is amazing, thanks so much. Just started using evernote and just found your blog. Sweet!

  • andrew

    hi ken,

    thanks for this great tip. but is there a way to tweak the applescript to import selected text into evernote, much as can be done through yojimbo? i often clip definitions from apple’s dictionary, and using the elephant in the menubar’s “paste to evernote” feature does a poor job, as it strips the rich text formatting.

  • awarre

    Just started using a Mac and have had Evernote acct for a while was excited to stumble on your blog but i can’t figure out how to get AppleScript into Automator Copy and Paste doesn’t work

  • Ken Clark

    Strange… I am not sure where the process is breaking on your machine. All you should have to do is copy the text from the text area in the blog post and then paste into the text area in the “Run Applescript” action in Automator. Worst case though is you might just want to retype it if you aren’t able to figure out what’s going on.

  • http://www.altimax-search.com Scott

    I took this a step further for ease of use and automation. For those of you with Hazel… I added a new automation with Hazel for a specific folder on my desktop called Scans. As soon as I scan a document into that folder, Hazel sees the file and runs an automator script. I used Ken’s script from above and created a Workflow (not a service) … the only other thing that had to be added was Get Selected Finder Items and I added it directly above the Applescript.

    In Hazel’s automation, simply define the folder that Hazel is to “keep and eye on” and set up the automation conditions to ANY file and the actions are 1. Run the Automator Workflow that you saved earlier and 2. Move the file to the trash. There are tons of others ways to do this, but this works great for my needs. I am a Premium Account Holder, and now that I have this running, I will scan EVERYTHING to Evernote.

  • Ken Clark

    Scott– That is a great idea. Very cool indeed! –Ken

  • Kirk Walchek

    I scan documents, receipts, etc into Photoshop. I usually save these as a PDF by choosing Print>Save as PDF. There are several workflows such as: “Save PDF to web receipts folder” and “Save PDF to iPhoto”.

    I'd like to write a workflow that would “Save PDF to Evernote”. Can you help me with that?
    Thanks,

  • teophag

    Absolutely cool, useful and intelligible walkthrough. Well done.

    For those who might wonder, in case you want to create a note from a text selection then you should replace “create note from file x” with “create note with text x” in the syntax.

  • Alan

    Great tip – note it also works on several selected files at once, have just imported a load of receipts and all appear as separate files

  • http://twitter.com/Ragart Thomas Wong

    Just wanted to say thanks for the tip! Migrated all of my Simplenote notes to Evernote for a new experiment.

    Cheers!

  • big opera

    i just get clipping source file does not exist

  • http://kenclark.me Ken Clark

    Thanks. No problem! Glad it worked for ya.

  • http://kenclark.me Ken Clark

    Could you tell me in a little more specifics what you are doing and when you get this error? Will help me try to troubleshoot.

  • http://www.facebook.com/scottdforeman Scott Foreman

    Ken – I’ve had to do this a few different times. It works for about a week, then stops, and I have to do this process over again. Why?

  • http://kenclark.me Ken Clark

    Scott, I am not sure. Since I wrote this post, I have stopped using Evernote in favor of Yojimbo, so I have not been using this service regularly enough to give recent, personal experience. Do you get an error message of any sort or does it just “not work”?

  • http://www.thadthoughts.com/?p=31 Scanning and Evernote: Mashup of the Week – Thad Thoughts

    [...] did some Google sleuthing and came up with this tutorial at KenClark.me.  It works perfectly (you will need to be using a Mac for this work work; the free [...]

  • http://www.facebook.com/ddejonghe Dominique Dejonghe

    so useful! Most interesting for Evernote power use is the Evernote Essentials eBook. Have a look here: http://goo.gl/AUb8b (affiliate link)

  • http://kenclark.me Ken Clark

    Thanks!

  • http://andrewdubber.net Dubber

    Stopped working for me too. Used to, and now it doesn’t. No error message – just no action.

  • Dubber

    Ignore my comment. Reinstalled the script and it’s working again – though not the Growl notification.

  • http://kenclark.me Ken Clark

    Dubber, I’m not sure what to tell you. It sounds like there could be a Services bug, but I can’t say for certain. Definitely frustrating.

  • http://twitter.com/cerithom Ceri Thomas

    I did this. Instead of creating a service in automator, create a Print plugin. All other steps are the same.

  • Paul

     Loved it. Worked perfectly with initial try and with 120 files!! Thanks…

  • Jbucchieri

    I like this, but can’t get keyboard shortcut to work.  Any suggestions. John

  • Jbucchieri

    I like this, but can’t get keyboard shortcut to work.  Any suggestions. John

  • http://kenclark.me Ken Clark

    It’s possible the shortcut you picked may conflict with another in OS X. Try to assign another keyboard shortcut and see if that works. If so, that is the problem.

  • http://kenclark.me Ken Clark

    It’s possible the shortcut you picked may conflict with another in OS X. Try to assign another keyboard shortcut and see if that works. If so, that is the problem.

  • Jlouis54

    tell application “Evernote”

    create note from file theFile
    

    end tell

    tell application “Finder”

    delete file theFile
    

    end tell

Previous post:

Next post: