Send to Evernote on Mac OS X
Tuesday, May 11, 2010 at 10:54PM |
Permalink 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:
- Open Automator and create a new service.
- Add the "Run AppleScript" action.
- Copy the script above into the new action.
- Set the service to receive selected "files or folders" (option located just above the action).
- 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.
AppleScript,
Evernote | in
Technology 

Reader Comments (9)
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.
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.
Thanks Stephen and Jaemie. The info you both shared has been immensely helpful!
Thank you very much. This has been extremely useful!
i would recommend http://clicktoapp.com
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
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 :-)
These services work fine on Lion:
http://ww.nik.me/crappysoftware/evernote-services-snow-leopard
Works like a charm! Thanks for posting!!