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
(* 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
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!
😀
Thanks it’s awesome.
One thing I think better for me is that I wont line brake after each post. Is that possible ?
Absolutely, Keizo!
Just edit that part out of the script that inserts the
between the posts!
could you help with the br between different posts (i don’t wanti it…) and the overalla font and size choice?
THX
amelchi
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”
I can’t seem to get it to work. I run it and nothing happens.
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!
Thanks Justin! I just tested it and it works great. Now I’m going to look up applescript handlers on the web to do some studying. Applescript is relatively new to me, although I hear that it’s limitless in its productivity potential. Any places to go to to learn more?
Rick,
Can’t remember if I already sent this to you, but I now have a page of resources for people who want to learn more about AppleScript and Automator!
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
Maybe Lew wants to jump in since this is his script but, for me, I’d try experimenting with these lines:
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!
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
Hi Nick,
I think this is possible…. I’ll probably take a shot at this and release it as a separate script soon!
-Justin