Add Entries to Day One via Text File

I use this setup to automate the addition of new entries in Day One by saving text files via Drafts to Dropbox. You lose the location and weather info, but those can be manually added. The Mac app doesn’t even support them yet anyways.

Since the Drafts setup is optional, I’ll save that for the end.

Install the Day One CLI

The Day One CLI allows you to interact with Day One behind the scenes.

Set up Hazel with the proper shell script

Using Hazel, you can automate the process when new files are added to the watched folder. By doing this using Dropbox, you can save new entries from any Dropbox-enabled text editor.

Here’s the shell script for the Hazel rule:

/usr/local/bin/dayone -d="$(GetFileInfo -d "$1")" new < "$1"

Save files with the proper title

Day One requires some particular file name titles for the import to work properly, and this avoids having to have the date and time in the entry itself, which doesn’t import nicely when using the CLI.

The proper format for the title is: 2013-03-21 3-47 AM.txt

Drafts integration

To integrate with Drafts, you’ll need to save the text files with the proper naming convention for Day One to pick it up and import it correctly. With Drafts’ templates, this is a breeze. Because of this, I find Drafts to be the ideal way to add new entries. But this could be done with any Dropbox-enabled text editor. But you’ll have to manually add the titles in the proper date/time format.

Here’s that date/time stamp so you can copy/paste: [[date|%Y-%m-%d %-I/%M %p]]

That’s it. Now you just set up Hazel to watch the folder where you’ll be storing your journal entries (in the screenshot you’ll see I’ve used “/Dropbox/Apps/Day One”), and have Hazel run that shell script.

I went a step further and set up Hazel to file these entries away in monthly folders after adding them to Day One. In fact, I went a further step further and set up another script that takes the content of this text file, prepends the date/time (from the file name) in my plain-text log file format, and then appends that to the plain-text log file. This is done with Hazel and some color label rules, as well as more shell scripts:

Prepend date and time script:

filename=$(basename "$1")
extension="${filename##*.}"
filename="${filename%.*}"
FILENAME_TRANSLATED=$(echo "$filename" | awk -F "-" '{print $1"-"$2"-"$3":"$4}')
FILE_CONTENT=$(cat "$1")
echo "## $FILENAME_TRANSLATED: $FILE_CONTENT" > "$1"

Append file contents to the Journal.txt file:

printf "\n" >> /Users/George/Dropbox/Notes/Journal.txt
cat "$1" >> /Users/George/Dropbox/Notes/Journal.txt

(Big thanks to a_freyer over on the Noodlesoft Forums for Hazel for helping me with these scripts to add to Day One, prepend the date/time, and append file contents)

One last tip: if you’re a Notational Velocity or nvALT user, you can use that app to quickly save new text files using the above method by setting up a Hazel rule to watch the NV folder for files named in a specific format, and whisk them over to your “Day One” folder we set up above. That way, when on the Mac you can quickly add a new text file for a journal entry by setting up a TextExpander snippet to title the file with the date/time in the right format (%Y-%m-%d %1I-%M %p), have Hazel watch for new files with titles formatted to meet the pattern:

All you need to do is activate NV, run the TextExpander snippet for the date/time for the title, hit return, type your entry, and hit Esc when done. It’ll get added to Day One, and if you set up the other shell scripts to add to the Journal.txt file, it’ll do those too.

And now you’re a nerd!

I’ve mentioned this in earlier posts, but the reason behind all this nonsense is to avoid being tied to one app. I love the idea of the plain-text log file, but I like viewing my entries in Day One. This way, I get both. It’s also MUCH faster to save thoughts this way, rather than launching the app, hitting new, etc. On the iPhone, I can quickly launch Drafts, write my entry, export using the Day One action, and it’s all done. I get the note in Day One, and the entry added to the plain-text log file with the date/time stamp format I like. Same on the Mac with the NV setup.

The other thing I’m doing is adding other stuff to the Journal.txt plain-text log file via IFTTT, which can’t be done with Day One. The Momento app does something very similar (and even exports in plain text), but adding manual entries is again a pain. I feel like eventually I will ditch all these apps for plain text, but I learned a few things setting all this up and it was a fun geek project for a few hours. I’ve just gotten so used to working with Drafts that going back to apps with multi-step interfaces for adding entries just leads me to stop journaling again. Plain text (and Drafts) makes it dead simple, and more likely to continue.

Advertisements

2 thoughts on “Add Entries to Day One via Text File

  1. George, did you manage to get the CLI to import with the correct time stamp?
    Here it always get the timestamp of import, not of file creation (actually, name of the .txt does not matter at all)

    1. If you follow my naming tips for the txt file, CLI will use that for the time stamp. You can also specify the time in the entry body, but I prefer this method. The Day One devs recommend exporting an entry to text file so you can see how the entry is parsed. Let me know if that helps.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s