Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
This script looks for text files in a specific folder modified today that include completed tasks ('@done') and timestamps, and then collects them into a daily log for the Day One journaling application. It works especially well when it's connected to IFTTT. See more details at Use this script if you are runn…
# Sifttter: An IFTTT-to-Day One Logger by Craig Eley 2014 <>
# Based on tp-dailylog.rb by Brett Terpstra 2012 <>
# Notes:
# * Uses `mdfind` to locate a specific folder of IFTTT-generated text files changed in the last day
# * The location of your folder should be hardcoded in line 53
# * Scans leading timestamps in each line matching today's date
# * Does not alter text files in any way
# * Changes ampersand ('&') to 'and' so the script keeps running
# * Does not require the Day One CLI tool
# * Only generates report if there are completed tasks found
# * Compiles all results into a single Day One entry
# * It's configured to locate a Dropbox-synced journal, so
# * If you use iCloud you'll can just uncomment lines 26 and 27, and comment line 28
# * To set the Day One entries to starred, just change `starred = false` to true on line 24
require 'time'
require 'erb'
require 'date'
uuid = %x{uuidgen}.gsub(/-/,'').strip
datestamp =
starred = false
# dayonedir = %x{ls ~/Library/Mobile\\ Documents/|grep dayoneapp}.strip
# dayonepath = "~/Library/Mobile\ Documents/#{dayonedir}/Documents/Journal_dayone/entries/"
dayonepath = "/Users/USERNAME/Dropbox/Apps/Day\ One/Journal.dayone/entries/"
template = <<-XMLTEMPLATE
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "">
<plist version="1.0">
<key>Creation Date</key>
<date><%= datestamp %></date>
<key>Entry Text</key>
<string><%= entrytext %></string>
<<%= starred %>/>
<string>daily logs</string>
<string><%= uuid %></string>
today ='%B %d, %Y')
cdate ='%m/%d/%Y')
files = %x{mdfind -onlyin /Users/USERNAME/Dropbox/IFTTT/Sifttter 'kMDItemContentModificationDate >= "$"' | grep -v -i daily | sort}
projects = []
files.each do |file|
if File.exists?(file.strip)
f =
lines =
project = "### " + File.basename(file).gsub(/^.*?\/([^\/]+)$/,"\\1") + "\n"
found_completed = false
lines.each_line do |line|
if line =~ /&/
line.gsub!(/[&]/, 'and')
if line =~ /#{today}/
found_completed = true
project += line.gsub(/@done/,'').gsub(/#{today}.../,'').strip + "\n"
if found_completed
def e_sh(str)
str.to_s.gsub(/(?=["\\])/, '\\')
if projects.length <=0
abort "No entries found"
if projects.length > 0
entrytext = "# Things done on #{today}\n\n"
projects.each do |project|
entrytext += project.gsub(/.txt/, ' ') + "\n\n"
fh =".doentry"),'w+')
fh.puts template.result(binding)
puts "Entry logged for #{today}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.