Hi, I am looking for a plugin that helps me get certain entries in Obsidian safely tucked away in DayOne (my go to app for journaling).
I found a lot where data flows from DO to Obsidian but I want it the other way around. Is there anything like that?
1 Like
Hi there,
I built a little script to do that for me. You need to install the Day One CLI module and update the paths as appropriate. As noted in the script, I don’t pull stuff right away, but rather let it slide 10 entries so that I can go back to fill in some details before it gets moved to Day One. Also adds a link to the original Obsidian entry so that you can jump back into Obsidian to leverage stuff like the graph view or internal navigation to other entries.
I run this on a daily cron job.
#!/bin/zsh
cd ~"/Library/Mobile Documents/iCloud~md~obsidian/Documents/Consulting/DailyNotes"
# get the number of entries so that the file list can be limited to all but the last 10 files so that I can go back and do updates on recent entries before getting committed to Day One
filecount=( $(ls | wc -l) )
(( filecount = $filecount - 10 ))
files=( $(ls | head -n $filecount) ) # get list of files in the directory
typeset -a imported=("${(f)"$(<imported.txt)"}") # import the previously imported notes list
declare -a toimport=()
# filter the previously imported files out of the list to be treated
for sourcefile in $files
do
if [[ $sourcefile =~ '[0-9]{4}-[0-9]{2}-[0-9]{2}\.md$' ]]; then
if [[ ${imported[(ie)$sourcefile]} -le ${#imported} ]]; then
#echo "$sourcefile already imported"
else
echo "$sourcefile to be imported"
toimport+=($sourcefile)
fi
fi
done
# Add the obsidian link to the original note and import into Day One
for file in $toimport
do
parts=(${(@s:.:)file})
filedate=$parts[1]
filelink="[obsidian](obsidian://open?vault=Consulting&file=DailyNotes/$filedate)"
sed -i '' -e '$a\' $file
echo $'\n\n' >> $file
echo $filelink >> $file
cat $file | /usr/local/bin/dayone2 new -j "Work" -z CET -d $filedate
echo $file >> imported.txt
done
Thank you very much! This seems to suit my needs just fine. I will experiment with it tonight to make sure I get it working properly.
1 Like