Evernote – New Note Based On Template

Description

Originally posted in this thread on the Evernote Forum: I made an AppleScript to implement templates. It uses Evernote's logic to create the note and opens upon completion, so you don't have to deal with importing & exporting files. The script assumes that your template lives in the same Notebook as the notes you'll be creating and is tagged "template".

The Code

tell application "Evernote"
   set {year:y, month:m, day:d} to (current date) --extract elements of the date for the title--
   set new_note_title to m & " " & d & ", " & y as string --this will be the title of your new note--
   set new_note_date to (current date) --change this to edit the creation date of the new note--
   
   set notebook_name to "Daily Record" --the notebook where your new note will be made & which contains your template--
   set template_tag to "template" --i assume your template will be tagged as a template--
   set tag1 to tag "daily_record" --a tag to assign to your new note--
   
   --This section extracts the template file & copes its contents as HTML--
   set template_list to find notes "notebook:"" & notebook_name & "" tag:" & template_tag
   --the above query must return ONLY the template you're looking for. in this case...'notebook:"Daily Record" tag:template'--
   set template_note to item 1 of template_list --gets the first matching item of the "find" command--
   set template_content to HTML content of template_note --grabs the template's content--
   
   --construct the note--
   set note1 to create note title new_note_title with html template_content created new_note_date notebook notebook_name
   assign tag1 to note1
   
   --Open the note in its own editor window & close the main window--
   open note window with note1
   if window 2 exists then
      close window 2
   end if
end tell
tell application "System Events" to set frontmost of process "Evernote" to true

One Response to “Evernote – New Note Based On Template”

  1. Fino January 29, 2012 at 8:11 am #

    This is a nice script, but it has its disadvantages. You must specify the notebook name in the script itself. This way, the script will only create a new note in that particular notebook. It would be nice to be able to create a new note in any notebook.