Evernote Templates on Mac OS X

A little while back I posted about an improved template system for Evernote. This system was based on exporting a note from Evernote, tweaking it in a text editor and then importing it back again whenever you need a new note based on it.  The post was focussed on how to do this in Windows as this is the platform I commonly work with.  I’m now starting to use Mac OS X a bit more and I’ve extended the system to work on this platform too.

The principles are essentially the same on OS X as they are on Windows.  The first step is to create a note in Evernote that will be the template you want to use.  Once you are happy with your template, you will want to export the note.  To do this examine the File menu in Evernote and chose Export… .  You can then save the note to a location of your choice.  Please note that you want to export in Evernote’s XML file format (ENEX format) and if you want your tags to remain intact (and I almost always do), ensure that the Include tags for each note tick box is ticked.  Evernote XML note files are of course the same across platforms so if you have any templates already on Windows or have some to download, then you can of course just copy them straight to your Mac (or use a file synchronisation and storage system like Dropbox to keep them in line).

Now we have our template exported we could just import it from here, but it’s worth tweaking the XML file a little bit so that we can do things like get the dates to more accurately match when we create the new note based on the template and not the date on which the template was exported.  To do this you’ll need to use a text editor such as the standard TextEdit app.

Once the note file is open in your text editor search through the file for two sets of XML tags (key words between angular brackets - not the same as Evernote tags) “<created>” and “<updated>” (this should be found just after the text “</content>”).  I don’t use geo-tagging, but it may be that some notes get exported with that so you might want to have a look for that too if you want to keep that data “clean”.  Once you have found the “<created>” and “<updated>” XML tags, delete them and any data contained within (e.g. <created>20100310T175541Z</created><updated>20100312T194829Z</updated>).  Once you have removed these XML data items, save and close the file.  You can of course edit the content at this point changing title’s, etc., but you can do most(/all?) of this before you even export.  Importing the file now will default the created and updated date and time to the time of import.

So our template is now ready to import.  On Windows this was done by using a batch script with a few parameters and a third party free application launcher that sits in the system tray.  On the Mac we are going to do things in a similar way, but as you might expect there are some differences.

On Windows I resorted to using the command line tool for Evernote known as ENSCRIPT.  The integration on the Mac for Evernote is through AppleScript and so we need a little bit of AppleScript to help us with the import.  I always describe myself as a “lazy programmer”.  I don’t want to create extra work for myself so I always look to write code that I can use elsewhere and not have to change to do it.  So my Windows batch file that calls ENSCRIPT uses parameters.  I was going to reproduce this in AppleScript but it really wasn’t worth it as the script is so simple and the easy way to run it is intrinsically linked to the script file.  So fire up your AppleScript editor and put the following few lines of code into it - we’ll need to amend it though.

tell application "Evernote"
    activate
    import "/Users/stephen/Documents/Evernote Templates/My First Template.enex" to "My Notebook" with tags
end tell

As you might guess the third line is the one we need to modify.  The text in double quotes immediately after the word import is the location of the template file we want to import. In this example the template file I’m importing is called ‘My First Template.enex’ and is located in a folder I created called ‘Evernote Templates’ within my ‘Documents’ folder.  Simply amend this to the location of the template file you exported earlier.

The next part of the line says ‘to “My Notebook”’.  This can be considered optional.  If you want the new note to be imported into a specific notebook, change “My Notebook” to the name of your notebook.  If you don’t specify it, it will just be imported into whatever your default Evernote notebook is.

The final part of the line specifies that you want to include the tags from your template note when you import it.  Again, you will usually want to do this.

Save the script to your scripts folder with a meaningful name.  I’ve created a sub-folder in my scripts folder just for Evernote, so in my case I saved the script to /Users/stephen/Library/Scripts/Evernote.  This script now appears in my scripts menu in my menu bar (in a sub-menu folder called Evernote).

Now if you’re familiar with AppleScript’ing, you might know that there are also scripting folders for applications.  In my case I have /Users/stephen/Library/Scripts/Applications/Evernote.  Putting the script file in here may seem like a better option than creating your own folder for Evernote scripts.  Well this is a ‘horses for courses’ choice. Personally I like to create a new note from a template in Evernote irrespective of what application I’m running at the time.  If I put the script in the Evernote specific folder then I’ll only see it when I’m already in Evernote.  Putting it in a folder that’s available all the time means I could be browsing the web, think to myself that I need to log a new idea into a new note based on a template and I can just have the script automatically activate Evernote and generate my new note.

Hopefully that’s fairly painless and now Evernote Mac users can also benefit from the efficiency improvements the template system can bring.

Author: Stephen Millard
Tags: | applescript | evernote |

Buy me a coffeeBuy me a coffee



Related posts that you may also like to read