Export of Day One journal entries and import into DevonThink

From your noodle to other noodles. Talk about ways to get the most from Hazel. Even exchange recipes for the cool rules you've thought up. DO NOT POST YOUR QUESTIONS HERE.

Moderators: Mr_Noodle, Moderators

Note:this workflow imports individual diary entries into DevonThink as markdown files. It is important to note that it will not import any Day One tags. Day One internal links are preserved and will open (in Day One) from DevonThink. The process is almost entirely automated by six Hazel rules and one DevonThink smart rule.

1. Export the relevant, selected diary entries from Day One in plain text/markdown format. Save the zipped file in a folder used only for that purpose (i.e., empty but for that file).
2. The first Hazel rule detects the ".zip" extension, unarchives the zip file and then continues matching rules.
3. The second Hazel rule processes the resulting Journal.txt file. It first runs the shell script:

Code: Select all
split -p '^    Date:' journal.txt out


(Note there is a tab before the word "Date:". You enter that by pressing ⌃V and then pressing the tab key.) That script splits the file into each individual entry. The same Hazel rule then renames the Journal.txt file "delete" and continues matching rules.
4. The third Hazel rule adds the .txt extension to each of the out* files created by the preceding rule (so that Hazel can read the files) and continues matching rules.
5. The fourth Hazel rule performs a date match on the first date in each file (which is the date of the journal entry), renames the out* .txt files with that date and continues matching rules.
6. The fifth Hazel rule renames each resulting .txt file with the .md extension in place of the .txt extension, moves the resulting files to the DevonThink global inbox and continues matching rules.
7. The final Hazel rule moves to trash the "delete" file created in step 3 (which leaves empty the folder into which you originally placed the .zip file).
8. A DevonThink smart rule detects any markdown file in the global inbox the name of which contains "day " (note the space). It scans the name of each file for the date following "*day " (set by the Hazel rule in step 5). That extracts the date which follows the day of the week in the filename. A DevonThink custom metadata date field "Journal entry date" is set to that date for each file, the file is locked and then moved to a folder in the relevant DevonThink database. (The purpose of the custom Journal entry date field is to ensure that entries can be easily displayed in date (or reverse date) order.)

I hope this may be of use to someone.

Stephen
Stephen_C
 
Posts: 42
Joined: Tue Sep 15, 2020 1:17 pm

Note that since the release of Hazel 5.1.2 (which recognises .md files as plain text) step 4 should be amended to add the .md extension (and not the .txt extension) to each of the out* files and to continue matching rules.

Step 5 will then perform the date match, rename the files with that date (retaining the .md extension), move the resulting files to the DevonThink global inbox and continue matching rules.

Step 6 is no longer necessary and steps 7 and 8 work as before.

Stephen
Stephen_C
 
Posts: 42
Joined: Tue Sep 15, 2020 1:17 pm


Return to Tips & Tricks - DO NOT POST QUESTIONS