Description
This AppleScript requires the download and installation of the DayOne Command Line App:
Download DayOne Command Line AppDay One is a journal / diary / text logging application for the Mac which has attracted a lot of positive attention: It has tremendous visual polish and appeal, prompts you to write daily, and it also has an iPhone / iPad app for when you're away from your computer.
Brian Stucki, the owner of macminicolo.net (and, perhaps, the person with the most awesome "Mac at Work" setup ever) recently reached out to see if I had any scripts in the pipeline to export Evernote items to Day One.
I didn't -- but I thought I'd quickly whip up one as a starting point for people to build on!
Script Notes
This AppleScript lets you select an item (or items) in Evernote and transfer a plain text version of that note into Day One. The creation date of the Evernote item is used for the entry date in Day One.
UPDATE #1: I've added a switch at the beginning of the script which, when turned on, creates a "header line" of the title of the Evernote item at the top of each new entry.
UPDATE #2 (December 2015): Veritrope reader Rob Record has kindly added tagging and Markdown support to version 0.98.1 of the script. Note: Markdown support requires an additional app called Pandoc and, once it's installed on your system, you can activate the feature by using the switch at the top of the script.
Since this is a "bare bones" version presented for people to discuss and play around with, I didn't put in any notifications or additional features. Highlight the item in Evernote, run the script, and look in Day One to confirm it arrived correctly.
The Code
◸ Veritrope.com
Export Evernote Items to DayOne
Modified by Rob Record
VERSION 0.98.1
December 15, 2015
// UPDATE NOTICES
** Follow @Veritrope on Twitter, Facebook, Google Plus, and ADN for Update Notices! **
// SUPPORT VERITROPE!
If this AppleScript was useful to you, please take a second to show your love here:
http://veritrope.com/support
// SCRIPT INFORMATION AND UPDATE PAGE
http://veritrope.com/code/export-evernote-items-to-day-one
// REQUIREMENTS
** THIS SCRIPT REQUIRES YOU TO DOWNLOAD THE DAYONE COMMAND LINE APP:
http://dayoneapp.com/downloads/dayone-cli.pkg
// CHANGELOG
Version
0.98.1 - Added support for tags and notebook name (as a tag)
- Added support for pandoc to convert to markdown
0.98 - UPDATED TO USE NEW CLI APP
0.91 - Added Optional Header
0.90 (Beta 1) - Initial Release
// RECOMMENDED INSTALLATION INSTRUCTIONS:
// TERMS OF USE:
This work is licensed under the Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License.
To view a copy of this license, visit http://creativecommons.org/licenses/by-nc-sa/3.0/ or send a letter to Creative Commons, 444 Castro Street, Suite 900, Mountain View, California, 94041, USA.
*)
(*
======================================
// USER SWITCHES (YOU CAN CHANGE THESE!)
======================================
*)
-- IF YOU'D LIKE THE SCRIPT TO NOT CREATE A
-- "HEADER LINE" FOR THE DAY ONE ENTRY USING
-- THE TITLE OF THE EVERNOTE ITEM, THEN
-- CHANGE THIS VALUE TO "false"…
property dayHeader : true
-- INSTALL PANDOC TO CONVERT TO MARKDOWN? (INSTALL PANDOC WITH HOMEBREW)
property convertMarkdown : false
(*
======================================
// OTHER PROPERTIES (USE CAUTION WHEN CHANGING)
======================================
*)
property noteName : ""
property noteCreated : ""
property noteHTML : ""
property noteLink : ""
property note_Date : ""
property noteTags : {}
property noteNotebook : ""
(*
======================================
// MAIN PROGRAM
======================================
*)
tell application "Evernote"
set selected_Items to selection
repeat with selected_Item in selected_Items
--GET THE EVERNOTE DATA
my getEvernote_Info(selected_Item)
--CONVERT HTML TO PLAIN TEXT
if convertMarkdown is true then
set note_Text to my convert_Markdown(noteHTML)
else
set note_Text to my convert_Plaintext(noteHTML)
end if
--CONVERT DATE TO PLAIN TEXT STRING
set note_Date to my convert_Date(noteCreated)
--ADD TAGS
set note_Text to my add_Tags(note_Text, noteTags, noteNotebook)
--MAKE THE NEW ITEM IN DAY ONE
my make_DayOne(noteName, note_Date, note_Text, noteLink, noteTags)
end repeat
end tell
(*
======================================
// PREPARATORY SUBROUTINES
======================================
*)
--GET THE EVERNOTE DATA
on getEvernote_Info(theNotes)
tell application "Evernote"
try
set noteID to (local id of item 1 of theNotes)
set noteName to (title of item 1 of theNotes)
set noteSource to (source URL of item 1 of theNotes)
set noteCreated to (creation date of item 1 of theNotes)
set noteModified to (modification date of item 1 of theNotes)
set noteTags to (tags of item 1 of theNotes)
set noteAttachments to {attachments of item 1 of theNotes}
set noteAltitude to (altitude of item 1 of theNotes)
set noteENML to (ENML content of item 1 of theNotes)
set noteHTML to (HTML content of item 1 of theNotes)
set noteLat to (latitude of item 1 of theNotes)
set noteLong to (longitude of item 1 of theNotes)
set noteNotebook to (name of notebook of item 1 of theNotes)
set noteLink to (note link of item 1 of theNotes)
end try
end tell
end getEvernote_Info
(*
======================================
// UTILITY SUBROUTINES
======================================
*)
--CONVERT HTML TO PLAIN TEXT
on convert_Plaintext(noteHTML)
set shell_Text to "echo " & (quoted form of noteHTML) & " | textutil -stdin -convert txt -stdout"
set note_Text to do shell script shell_Text
return note_Text
end convert_Plaintext
--CONVERT HTML TO MARKDOWN
on convert_Markdown(noteHTML)
set shell_Text to "echo " & (quoted form of noteHTML) & " | /usr/local/bin/pandoc -s -f html -t markdown_github"
set note_Text to do shell script shell_Text
return note_Text
end convert_Markdown
--CONVERT DATE TO PLAIN TEXT STRING
on convert_Date(noteCreated)
set AppleScript's text item delimiters to ""
set m to ((month of noteCreated) * 1)
set d to (day of noteCreated)
set y to (year of noteCreated)
set t to (time string of noteCreated)
set date_String to (m & "/" & d & "/" & y & " " & t) as string
return date_String
end convert_Date
--ADD TAGS TO NOTE TEXT
on add_Tags(note_Text, noteTags, noteNotebook)
set noteTagsText to ""
if noteTags is not {} then
repeat with i from 1 to count of noteTags
set noteTagsText to noteTagsText & "#" & (name of item i of noteTags) & " "
end repeat
end if
if noteNotebook is not "" then set noteTagsText to "Notebook: #" & noteNotebook & "
" & noteTagsText
return note_Text & "
" & noteTagsText
end add_Tags
--PARSE HTML
on parse_HTML(note_Text)
return note_Text
end parse_HTML
(*
======================================
// MAIN HANDLER SUBROUTINES
======================================
*)
--MAKE ITEM IN DAY ONE
on make_DayOne(noteName, note_Date, note_Text, noteLink)
if dayHeader is true then set note_Text to (noteName & return & return & note_Text)
set new_DayOne to "echo " & (quoted form of note_Text) & " | '/usr/local/bin/dayone' -d="" & note_Date & "" new"
do shell script new_DayOne
end make_DayOne
HI
Tnx for this script which works a charm!
Any way to add the tittle of the note from Evernote as the first line in Day One (if this makes sense)
Leonardo
Hi,
Is that possible to add the tags used in Evernote notes to the new Day One entries?
Thanks in advance for your help. 🙂
Regards,
-MATSYA-
Worked like a charm! Transferred over 1000 entries from Evernote to Day One (several years worth of diary). Not sure how long it took, as I started the job and went to sleep. Was done in the morning.
Thanks for the great script!
I am having trouble on Mac 10.8. I get the error “sh; /usr/local/bin/dayone: No such file or director.”
Thanks for any help you could give.
Hi David,
Double-check that you’ve downloaded and installed the DayOne Command Line App (link is at the top of the post).
Justin, none of the Evernote notes containing images makes it over into DayOne. Possible to bring those items over with images into the images section of DayOne? Steve J
I have saved the script as both an application and a script. I can not figure out how to run it from within Evernote. Launching the application does nothing, even if I have selected items in Evernote.
p.s. Tabbing from the “Name” field at the left of this comment field jumps me to a spot somewhere up the page. Tab order quandry, perhaps?
Okay… first, AppleScript’s menu item needs to be turned on, found in the preferences of the AppleScript Editor application found in the Utilities folder. Next, you can use that menu to open the Evernote scripts folder. Place the script, saved from the editor as a script and NOT an application, into that folder. Or use the Move To… function in the applescript editor. Then select an item in Evernote and select the script from the applescript menu. Perhaps there is another way to do this, but I recommend adding a few hints here or in your Applescript intro doc. Thanks for the awesome script!