Evernote Daily Diary

Description

NOTE: I have added a new portion to the script so that users who aren't familiar with how to use a handler can run the Script directly. If you'd like to use this as a handler in your own AppleScript, Just delete or comment out the portion of code between "BEGIN HANDLER CALL" and "END HANDLER CALL" -- JUSTIN Modified from an older post on Juggling Eggs...this script creates a notebook called Daily Diary and then creates a new note for the day with the date as the title. If the note exists then content is appended. You send it a bit of text and it creates a diary entry. It also asks if you'd like to append the clipboard contents. I'm using it with LaunchBar to create quick notes throughout the day. FYI -- The full script that <a href="http://www.obdev.at/products/launchbar/index.html"integrates with LaunchBar uses this to call the handler: on handle_string(notetext) if notetext is not "" then CreateDailyEvernote(notetext) end if end handle_string

The Code

property nb : "Daily Diary"

(* BEGIN HANDLER CALL

NOTE:  I have added a new portion to the script so that users who aren't familiar with how to use a handler can run the Script directly and check it out.

If you'd like to use this as a handler in your own AppleScript, Just delete or comment out the portion of code between "BEGIN HANDLER CALL" and "END HANDLER CALL"!
*)


set notetext to text returned of (display dialog "Diary Entry" default answer "")
my handle_string(notetext)

on handle_string(notetext)
    if notetext is not "" then
        CreateDailyEvernote(notetext)
    end if
end handle_string

(* END HANDLER CALL *)

on CreateDailyEvernote(txt)
    set t to do shell script "date +'%Y/%m/%d'"
    set timeStr to time string of (current date)
   
    tell application "Evernote"
        set foundNotes to find notes "notebook:"" & nb & """ & " intitle:"" & t & """
        set found to ((length of foundNotes) is not 0)
        if not found then
            set curnote to create note with html "<h1>Entry : " & timeStr & "</h1>" title t notebook nb
            tell curnote to append html "<br>"
            tell curnote to append text txt
            tell curnote to append html "<br>"
            set question to display dialog "Include clipboard?" buttons {"Yes", "No"} default button 2
            set answer to button returned of question
           
            if answer is equal to "Yes" then
                if (the clipboard) is not "" then
                    tell curnote to append html "<h1>Clipboard</h1>"
                    tell curnote to append text the clipboard
                end if
            end if
            tell curnote to append html "<hr>"
        else
            repeat with curnote in foundNotes
                tell curnote to append html "<h1>Entry : " & timeStr & "</h1>"
                tell curnote to append text txt
                tell curnote to append html "<br>"
                set clipTxt to the clipboard
               
                set question to display dialog "Include clipboard?" buttons {"Yes", "No"} default button 2
                set answer to button returned of question
               
                if answer is equal to "Yes" then
                    tell curnote to append html "<h1>Clipboard</h1>"
                    tell curnote to append text the clipboard
                end if
               
                tell curnote to append html "<hr>"
            end repeat
        end if
        activate
    end tell
end CreateDailyEvernote

15 Responses to “Evernote Daily Diary”

  1. Justin Lancy September 9, 2010 at 3:21 pm #

    This is fantastic, Lew — I can’t wait to try this out!

    I’ve been working on a few variations of the daily log myself since the append function appeared in the beta, and I think seeing your code here will kick-start the imaginations of any number of Evernoters!

    😀

  2. Keizo September 14, 2010 at 3:01 am #

    Thanks it’s awesome.

    One thing I think better for me is that I wont line brake after each post. Is that possible ?

    • Justin Lancy September 14, 2010 at 3:47 am #

      Absolutely, Keizo!

      Just edit that part out of the script that inserts the

      <br>

      between the posts!

      • amelchi August 27, 2011 at 6:34 am #

        could you help with the br between different posts (i don’t wanti it…) and the overalla font and size choice?
        THX
        amelchi

        • Justin Lancy August 27, 2011 at 6:49 am #

          As mentioned in this comment, you’ll want to adjust the HTML Header tags (“h1”) to adjust the size of the font. Try “h2” or “h3” and see if you like the result.

          As far as the “br”, just delete them from the script in the places you don’t want them to appear. If you don’t want the horizontal line between entries, delete the line with “hr”

  3. Rick September 14, 2010 at 12:57 pm #

    I can’t seem to get it to work. I run it and nothing happens.

    • Justin Lancy September 14, 2010 at 1:55 pm #

      Hi Rick,

      This bit of code is called a “handler” (or a “subroutine”) — which means it’s used as a part of a larger AppleScript. This is why you can’t run it directly.

      I’ve gone ahead and altered the code for you so you can check it out more directly! Just click on the “Open in Script Editor” link after the source code box (or you can cut and paste the code into your editor) and you should be able to run it from there.

      Have fun!

  4. Steven T. November 14, 2010 at 4:17 am #

    Thanks for the great script. I’m new to apple script, but am a long time user of evernote and found the above very useful.

    Question, how do I reduce the font size of the heading of each entry. I’m sure it involves modifying the html header in the following portion of the script:

    Entry : ” & timeStr & ”

    I’ve tried to change the entry from h1 to h6 (smaller heading), but that had no effect on the size of the font, which is currently twice the size of my normal note font.

    Any help appreciated from a script newbie.

    Thanks,
    Steve

    • Justin Lancy November 14, 2010 at 12:50 pm #

      Maybe Lew wants to jump in since this is his script but, for me, I’d try experimenting with these lines:

      set curnote to create note with html "<h1>Entry : " & timeStr & "</h1>" title t notebook nb
      tell curnote to append html "<h1>Entry : " & timeStr & "</h1>"
      tell curnote to append html "<h1>Clipboard</h1>"

      The first line formats the header for a new Diary entry if none exists, the second for an addition to an existing diary, and the third for Clipboard items pasted.

      Try changing the header types in each (or removing them) and I expect you’ll see things start to look different in Evernote. Adjust it to taste and you should be all set!

      Let us know how it goes!

  5. Nick Wild November 19, 2010 at 7:05 am #

    Hi,

    Excellent solution many thanks.

    Is it possible to add tags and/or the notebook as variables that can be parsed from the usual @ and # entered in the text string?

    This would then be the ultimate solution for notetaking
    Thanks

    Nick

    • Justin Lancy November 20, 2010 at 12:09 pm #

      Hi Nick,

      I think this is possible…. I’ll probably take a shot at this and release it as a separate script soon!

      -Justin

Trackbacks/Pingbacks

  1. Evernote Daily Dialyが熱い - January 5, 2014

    […] Evernote Daily Diary – Veritrope Modified from an older post on Juggling Eggs…this script creates a notebook called Daily Diary and then creates a new note for the day with the date as the title. If the note exists then content is appended. […]

  2. Evernoteへ超絶簡単にメモ出来るスクリプトがとにかく素晴らしすぎる! | ごりゅご.com - February 19, 2017

    […] Evernote Daily Diary | Veritrope […]