Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- # This is the path to the directory containing the individual journal .note files
- JOURNAL_PATH=/Path/To/Your/Journal/Entries
- # This is the path to the log of successful Supernote -> DayOne transfers
- LOG_PATH=/Path/To/Your/Log/DayOneTransferLog.txt
- for f in "$JOURNAL_PATH"/*.note;
- do
- filename=$(basename "$f")
- if grep -Fxq "$filename" "$LOG_PATH"
- then
- # the transfer log says this file has already been added, so skip this one
- continue
- else
- # this file is not already in the transfer log
- # use supernote-tool to extract the handwriting recognition text
- supernote-tool convert -t txt -a "$JOURNAL_PATH"/"$filename" "$JOURNAL_PATH"/temp_output.txt
- if [[ -f "$JOURNAL_PATH"/temp_output.txt && -s "$JOURNAL_PATH"/temp_output.txt ]];
- # The supernote-tool command produced an output file, and it isn't empty
- then
- echo "text found"
- entrydate=`echo $filename | sed -E 's/([0-9]{4})([0-9]{2})([0-9]{2})_([0-9]{2})([0-9]{2})([0-9]{2}).note/"\1-\2-\3 \4:\5:\6"/g'`
- echo "$entrydate"
- # Command to make a new DayOne entry
- dayone2 -j Journal -t supernote "machine transcription" -d "$entrydate" new < "$JOURNAL_PATH"/temp_output.txt
- # Log this filename so it won't be added to DayOne again
- echo "$filename" >> "$LOG_PATH"
- else
- # The supernote-tool command did not produce an output file, or it produced an empty file
- echo "no text found"
- fi
- # remove the supernote-tool output file
- rm "$JOURNAL_PATH"/temp_output.txt
- fi
- done
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement