Search
« Evernote watched folders on OS X | Main | Get the path for a file in OS X with an AppleScript »
Tuesday
May112010

Send to Evernote on Mac OS X

Being able to add files into Evernote is a particularly useful feature.  On my Windows PC I have an option when I right click on a file to send it to Evernote.  By default my Evernote installation on my Mac doesn't provide this option, so I decided to address this shortcoming with a service.

Automator allows you to create new services and these can form the basis for context sensitive options.  I set about writing an AppleScript that would take selected files and import them into Evernote.  The script below is what I came up with.

on run {input}
	tell application "Evernote"
		repeat with SelectedFile in input
			try
				create note from file SelectedFile notebook "Auto Import"
			on error errMessage number errNumber
				
				if the errNumber is equal to 4 then
					-- The file being imported is not supported
					set userCanceled to false
					try
						display dialog "Your Evernote account does not support the import of this type of file.  Why not consider upgrading?" buttons {"Cancel", "Go Premium"} default button "Cancel" cancel button "Cancel" with icon caution
					on error number -128
						set userCanceled to true
					end try
					
					-- If the user wishes they can be taken to the Evernote premium upgrade page
					if userCanceled is false then
						tell application "Safari"
							activate
							open location "https://www.evernote.com/Checkout.action"
						end tell
					end if
				else
					-- Unspecified failure
					display alert "Import into Evernote failed" message "Error(" & errNumber & "): " & errMessage as warning
				end if
			end try
		end repeat
	end tell
end run

The script includes some error handling.  One specific error I've pulled out is for error number 4 - which is flagged up by Evernote when a file being imported is not permissible by the account type (i.e. you're a freemium user with trying to import an unsupported file type).  Originally I targeted looking at file sizes in Finder before passing them to Evernote as freemium and premium have two different file size limits.  However when Evernote receives a request to create a note from a large file that is not supported by the freemium account it gives an option for the user to upgrade.  Oddly Evernote didn't seem to do this for unsupported files so I decided to include this in the script.  Non-specific errors are also relayed to the user through a dialog displaying the standard error message and number.

To make this a service, follow these steps:

  1. Open Automator and create a new service.
  2. Add the "Run AppleScript" action.
  3. Copy the script above into the new action.
  4. Set the service to receive selected "files  or folders" (option located just above the action).
  5. Save the service with a suitable name.

Open Finder then locate one or more files to import into Evernote.  Right click to display the context menu and select the name of your service.  This should then begin the process of creating a note for each file in Evernote.

PrintView Printer Friendly Version

EmailEmail Article to Friend

Reader Comments (28)

Great script! Thank you for posting.

I made a slight modification. I wanted the item that was placed into the faux watched folder to be sent to the trash once processed, so I added the following after end tell, but before the end repeat.

tell application "Finder"
delete the this_item
end tell

Now I'm just trying to get the "move to trash" sound to stop playing when this runs.

To further automate this, I have set up a synchronized folder through Dropbox that allows me to drop items into Evernote from work. Sure, I can put the client on my work computer, but I like to keep personal stuff personal - and not keep personal information stored on my work computer.

June 11, 2010 | Unregistered CommenterJaemie

Jaemie. Glad you found it useful. I had considered moving it to trash, but I often just want a copy in Evernote and to keep the original so I left this out.

With regards to the trash and sound annoyance, perhaps the following might be the answer for you:
http://stackoverflow.com/questions/2918120/delete-file-without-playing-sound-in-applescript.

I'm also a huge fan of Dropbox and use it daily. I guess you're not as precious about work stuff on a personal computer as personal stuff on a work computer if you are using Dropbox across them. So what is your personal computer? If it's a PC I'm presuming you set-up a watched folder in Dropbox, and if it's a Mac I assume you set up a folder action to import into Evernote. I was never sure if the OS's would be smart enough to wait for Dropbox to sync before triggering the import actions, but I use Evernote everywhere so it was never an issue for me.

June 11, 2010 | Registered CommenterStephen Millard

Thanks Stephen and Jaemie. The info you both shared has been immensely helpful!

July 30, 2010 | Unregistered CommenterFern

Thank you very much. This has been extremely useful!

May 28, 2011 | Unregistered CommenterMike

i would recommend http://clicktoapp.com

September 23, 2011 | Unregistered Commenterjoseito

Thanks for the great tip and applescript to send files right into Evernote. I created a How-To YouTube video outlining this procedure using your code but gave you full credit for it and links back to this post. Let me know if this is a problem and I will take it down. Thanks again.

http://www.youtube.com/watch?v=ykb-HrTF2ss

October 18, 2011 | Unregistered CommenterAdam Stauffer

Adam - no problem at all. In fact I'm really happy that someone found this so useful they wanted to make a video how-to. Hopefully more people will find the links and get the benefit from this import option.

NB: I amended your comment above to make the link clickable :-)

October 22, 2011 | Registered CommenterStephen Millard

These services work fine on Lion:

http://ww.nik.me/crappysoftware/evernote-services-snow-leopard

November 19, 2011 | Unregistered Commenternev

Works like a charm! Thanks for posting!!

March 11, 2012 | Unregistered CommenterAngie Bartos

I followed the steps above and the new service is successfully sending the files to Evernote. However, when it does so, something is triggering Safari to open (even though Chrome is my default browser) with the bizarre URL below. I've tried this with multiple files, closing Safari after each attempt, and am seeing the same behavior.

I'm running OSX 10.7.3.

Any thoughts would be much appreciated.

http://1.1.1.1/fs/customwebauth/login.html?switch_url=http://1.1.1.1/login.html&ap_mac=00:23:eb:e6:31:a0&wlan=VB_LIBRARY&statusCode=1

May 11, 2012 | Unregistered CommenterMichael Harvey

Michael.

That is very strange. I did a quick Google search for "fs/customwebauth/login.html". Everything that comes back seems to relate in some way to logging into Cisco secured/powered systems. Do you have any Cisco software installed or are you connected to any Cisco hardware?

Safari opening rather than Chrome is because of line 19. I almost exclusively use Chrome, but I needed to give the script a browser that every Mac would have ... though maybe there's an alternate way to script this to use the default browser (I'm an AppleScript user rather than guru)?

So what I think is happening is that you're getting some sort of error and it's trying to then send you out to the Evernote site to sign up for a premium account; but I think this is where you're hitting a login request for some router or VPN? So as a quick hack I'd suggest just removing (or commenting out) lines 6 to 27 which do the error handling.

if you want to keep the error handling in maybe just add your own "do nothing" script in for error number 4?

Hope that helps.

June 20, 2012 | Registered CommenterStephen Millard

Thanks for this. Where should the additional steps for deleting the item go?

September 14, 2012 | Unregistered Commenterdenno

Hello Stephen-

Thank you for creating this very useful action. I have implemented it on my Mac and it now displays when I right click on a file, and it sends it to Evernote beautifully. I am a bit confused on one thing. Does this action create a folder someplace where if a file is dropped in the folder it sets off the action and sends it to Evernote. That would be very useful to me. I do medical research and I would like to be able to download a PDF file of an article directly to Evernote. So I am hoping I can create an auto-import folder on my desktop with this action assigned to it, and then just choose that folder when I download the PDF and have it end up in Evernote. Now that I have implemented this automator action is there a folder like that somewhere I am missing? I followed Adam Stauffer's youtube video demonstrating how to install your action.

Thanks!

Steve Rosenblum

September 22, 2012 | Unregistered CommenterSteve Rosenblum

Denno

Jaemie added the deletion lines "after end tell, but before the end repeat" so that would be between lines 28 and 29.

September 27, 2012 | Registered CommenterStephen Millard

Steve Rosenblum.

This blog post is about how to create a service to allow you to send a file to Evernote. There's actually another post on this site about setting up a watched folder to send files to Evernote which I think is exactly what you want.

As a final point, the method described in this post does not create any sort of watched folder.

September 27, 2012 | Registered CommenterStephen Millard

Thank you for this post! This is exactly the feature I needed to process old documents on my Mac. Much obliged.

November 8, 2012 | Unregistered CommenterValdimar

Stephen - this post keeps on giving. I've passed it along to half a dozen coworkers, and it continues to be helpful (especially when the evernote v5 upgrade broke this). Thanks.

November 28, 2012 | Unregistered CommenterJeff Krueger

Thank you! That was exactly what I was looking for!

November 30, 2012 | Unregistered CommenterDavid

Thanks for the positive feedback guys :-)

November 30, 2012 | Registered CommenterStephen Millard

How do I modify the name of the folder it is imported into? Can I modify the Service?

Thank you

June 25, 2013 | Unregistered CommenterJessica

Is there a way to get the note that was created in Evernote, using this process, to create the note in a particular folder, i.e. "Inbox"?

Thank you!

June 30, 2013 | Unregistered CommenterRatherbeinmaui

This is brilliant. Couldn't get the folder action to work (different blog entry), but this worked like a charm. Very clear instructions.

Again, thanks, saving me tons of time.

James

August 30, 2013 | Unregistered CommenterJames

Hey does this script need a update because of OSX10.9 or the new version of Evernote?

Im getting a failure

January 15, 2014 | Unregistered Commentermvaneijgen

Jessica.

Assuming you mean notebook rather than folder, change "Auto Import" on line 5 to the name of your desired notebook to import into.

March 2, 2014 | Registered CommenterStephen Millard

Ratherbeinmaui.

Changing "Auto Import" on line 5 to "Inbox" should create the note in your inbox.

I'm not sure if "is there a way to get the note that was created in Evernote" is covered off by the above, but if you really needed to identify the note then searching for the file name as the note title in the specified notebook created in the last few minutes. This could be a manual search or you could write some AppleScript to do it ... is it that you want to automatically open it up in Evernote?

FYI if you want to specify a time frame probably the best way to do it would be to capture the time when the script begins to run then use it to populate a created parameter for the search query...

e.g.
created:20140302T093000
Matches notes that were created on or after 9:30am on 2 March 2014, based on the your Mac's time zone.

March 2, 2014 | Registered CommenterStephen Millard

Mvaneijgen.

I'm running OS X 10.9.2 with Evernote client 5.5 without any issues on using this.

Could you share what error you are getting, whether you are a premium account holder and some details about the file you are sending to Evernote (file type, size)?

Are you able to manually add it to a note without any issues?

Regards,

Stephen.

March 2, 2014 | Registered CommenterStephen Millard

Hi,

Just wanted to let you know I'm running Evernote 6.05 and OS X 10.8.5
If I right-click a file in Finder I get an option Add to Evernote at the bottom of the menu.

Looks like it's been implemented =)

January 29, 2015 | Unregistered CommenterReece

I couldn't find step 4 ! Please help, thanks.

May 9, 2015 | Unregistered CommenterIan

PostPost a New Comment

Enter your information below to add a new comment.
Author Email (optional):
Author URL (optional):
Post:
 
Some HTML allowed: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <code> <em> <i> <strike> <strong>