Use Mac OS X Services to Import Files into Evernote

by Ken Clark on 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.
  • Ken Clark
    Andrew--

    Thanks for all the great work on the Mac app. Evernote really rocks. --Ken
  • Ken,
    Both the concept and your walk-through are fantastic - Nice work!

    Justin
  • Ken Clark
    Justin, thanks! I am really enjoying both Evernote and Services. It was a nice way to link the two together.
  • 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??
  • 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
  • Stan Scott
    Utility works like a charm. Thank you!!
  • Ken Clark
    Thanks Stan. Glad it worked for ya!
  • 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.
  • 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
blog comments powered by Disqus

Previous post:

Next post: