Skip to main content

Scripting Evernote in Windows

Note: 

This post was updated in June 2017.  Please go to that post and ignore this one.




Evernote is one of those applications with a lot more power then is immediately evident. For example, Podcast #9 debuted yesterday, and they talk about Saved Searches. As part of that, they talk about their rich search vocabulary and how they have hidden that ability in the API documentation.

Another wonderful ability not obvious until you search around on their website, is Evernote's scripting capabilities. They have one for Windows they built called ENScript, and another for the Macintosh. Of course, they have their full fledged API as well, but for a hobbyist programmer like myself, the scripting was intriguing.

I've been playing around with the scripting and thought I'd share an example script showing the kind of power it gives an Evernote user with just a little bit of programming ability.

Before we all began using Evernote, we all had data in a variety of file formats. Text files, PDF's, and Delicious bookmarks are all easy to move into Evernote. Excel spreadsheets can be moved into Evernote if you have a Premium account. What if instead of moving an entire spreadsheet, you instead want to create a note from each line of data in a spreadsheet?


Setup and Running a Test:

While I could have done this project using Excel's built in scripting tool, Visual Basic for Applications, I decided instead to use a wonderful, and free, scripting tool called Autoit. A future project I'll blog about soon couldn't be done with VBA but could be with Autoit. And after doing this project in VBA, I re-did it in Autoit and found Autoit did it more elegantly. So I will standardize on Autoit for my Evernote scripting examples I'll show here starting with this post.

Autoit is very reminiscent of my favorite rendition of Visual Basic, their 3.0.

Autoits power can be extended by users. For this project I needed the ability to link to Excel. I found that through a User Defined Function by a user calling himself Locodarwin.

Note: Links to the various files you'll need for this project are listed together at the bottom of this post.

Step 1: Download and install Autoit3.

Step 2: Download Locodarwin's Excel.Zip file

Step 3: Unzip the file to its own folder

Step 4: Copy the excel.au3 to Autoit's Include folder. If you installed Autoit3 to its default loation, the include folder is at : C:\Program Files\AutoIt3\Include

Step 5: Download this script : Excel_to_Evernote.au3. It does not matter where you install it.

Step 6: For testing, download the spreadsheet, books.xls.

Step 7: You'll need to load the script into an editor (Notepad will do) and change the line :

$sFilePath = "C:\Documents and Settings\Mark\My Documents\Evernote\excel_to_en\books.xls"

to have the path to your books.xls file.

Note: You will need Excel to run this script. I used Excel 2003, but theoretically it should work on later versions too. If it does not, please note in the comments.

Also, to keep the script fairly clean and easy to read, I really don't have any error checking in it.

Warning: This script is provided AS-IS with no warranties. I strongly urge you to copy your Evernote Database file to another location in case anything in this script were to mess you up. It shouldn't but you never know.

Step 7: In Evernote, create a notebook called "books". You can make it unsynchronized to save on your 40 or 500 meg upload quota.

Step 8: Run Autoit. It will prompt for the script file to run. Point it at "Excel_to_Evernote.au3" script. Additional script running methods are available in the Autoit Help file.

When the script runs it will start Excel with the Books.xls file in it. It will take a minute or so to run, and then give you a message box indicating it is done. The script, and Excel will then end.

Evernote needs another minute to process in the incoming information. Then you'll see this in the Books Notebook :




Modifying the script to import you own data:

You can modify the script to bring in your own spreadsheets from Excel.

Bring up the script in your own editor (like Notepad). The pertinent section is the "Information about your spreadsheet" section.

Note: text in the script after a semi-colon in the code is a comment.

Change this to the path and name of your own spreadsheet :

$sFilePath = "C:\Documents and Settings\Mark\My Documents\Evernote\excel_to_en\books.xls"


Change this to list the columns you want to move to a note. The first column becomes the title and first line. The subsequent columns become the next lines of the note :



$columns = "A,C,E"


Show the first row in the spreadsheet to list. It must have data in it
.



$row_start = 3



Indicate the row to stop on. The script will stop before this if it finds a blank cell in the first column chosen above.



$row_end = 15



You probably won't need to change this line if you installed Evernote in the default location:



$pathToENScript = "c:\program files\evernote\evernote3\"



The script takes the contents found in cells in the first column and makes them the title of the note. You can put in text to put before that data in the title:


$ENTitle = "James Michener Books:"



Notes will be placed in the Evernote notebook you specify here :



$ENNotebook = "books"


Each note will have the tags you list in this comma separated list :

$ENTags = "book to read,michener"



How does the script work?

Basically all this script does is walk through the spreadsheet gathering the data in the appropriate columns in a row.

Then it writes a temporary temp file with the data.

Then it invokes ENSCRIPT.exe, Evernotes script engine, to create a note from the text file, with the title and tags specified, and in the specified notebook.

Then it moves on to the next row until it reaches the first row where the first column is blank, or the last row is reached.



Concluding Notes

I realized after creating this script, and starting on the next one I'll share with you in a future post, I could have instead generated an XML file with the spreadsheet data and then imported that into Evernote. That method would require only one invocation of ENSCRIPT instead of one for each record. But it would have been less illustrative then this method.

Files you need to download:

AutoIt3 Install

Excel.zip

Excel_to_Evernote.au3 (broken link fixed - May 2017, new version added June 2017)

Books.xls (broken link fixed - June 2017)


Be sure to comment if you have questions or would like share something about Evernote and scripting.

Comments

  1. As the author of the mentioned Excel UDF, I'm happy that you've found a good use for it. I am also an Evernote user and I like your tips!

    ReplyDelete

Post a Comment

Popular posts from this blog

Notes Folder : My new note taking system

I'm in the process of moving to a new way to keep my notes. It would be best to make a separate post on my long time notetaking app, Evernote, and how it now disappoints me.  Bottom line, I no longer trust the company behind Evernote since it was acquired. My first inclination was to finally look at alternatives. like Notion, Joplin, Obsidian, etc. of I was not enamored with any of them, so I gritted my teeth and stayed with Evernote. TThe situation made me think about how I use Evernote. To keep up additional posts on this topic, search on the tag Notes Folder Updates : January 24, 2024 and in updates noted here. Most of the things I store are quick notes, lists, online receipts for online bills, that sort of thing.  Kind of an online file cabinet if you will. If I were a doctoral student though I could see storing PDFs of papers and research materials.  If were working on a large project, then plans, communications etc. would all be there. Back when I began using Evernote way b

Recording your own notes with Google Voice

Note :   April 2016:  Frankly I don't know if this works anymore.  It is 7 years old. I stopped using this when Google Now became useful on my phone, and I could dictate reminders using it. I found a way a while ago to use Google Voice to record a personal note, transcribe it, and email it to me. A recent Lifehacker post "Five Things We'd Like to See in Google Voice" lists that need as their #5 request, so I realized what I'd figured out is not common knowledge. In GV's Contacts, create a Group "Special Transcription" To avoid listening to my standard voice mail when I call, I recorded a short voice mail greeting for this group simply saying "Record note now" I added a contact with my own cell phone number as the only number, and made it the sole member of this group. In GV's phone settings, I edited the settings for my cell phone. In the section "Direct access to voicemail when calling your Google number from th

Ten Years of Evernote

This blog post was set to publish exactly as the day begins on Tuesday, July 31, 2018. That is ten years to the day after my first Evernote  post. With my second note, I was already getting down to business; recording the agreement I'd come to on the phone on a minor business matter. My affection for Evernote has not dimmed since that day ten years ago. Since then, I've accumulated about 7.8 new notes a day. Ironically, I have needed to pull up only a few notes a year. Yet, when I need them, I need them badly and am glad to have Evernote all over again. My philosophy of what to capture is simple : If you encounter something you might remotely want to see again, it goes into Evernote. from a blog post June 1, 2015 I've written here about Evernote than any other topic.  Even wrote a now horribly out-of-date book. Don't get me wrong. If something better comes along that imports my Evernote notes well, I can be enticed to move.  But in t