Advertisement
glorioushubris

Script to transfer Supernote entries to DayOne

Nov 11th, 2024 (edited)
235
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.49 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. # This is the path to the directory containing the individual journal .note files
  4. JOURNAL_PATH=/Path/To/Your/Journal/Entries
  5. # This is the path to the log of successful Supernote -> DayOne transfers
  6. LOG_PATH=/Path/To/Your/Log/DayOneTransferLog.txt
  7.  
  8. for f in "$JOURNAL_PATH"/*.note;
  9. do
  10. filename=$(basename "$f")
  11. if grep -Fxq "$filename" "$LOG_PATH"
  12. then
  13.   # the transfer log says this file has already been added, so skip this one
  14.   continue
  15. else
  16.   # this file is not already in the transfer log
  17.   # use supernote-tool to extract the handwriting recognition text
  18.   supernote-tool convert -t txt -a "$JOURNAL_PATH"/"$filename" "$JOURNAL_PATH"/temp_output.txt
  19.   if [[ -f "$JOURNAL_PATH"/temp_output.txt && -s "$JOURNAL_PATH"/temp_output.txt ]];
  20.     # The supernote-tool command produced an output file, and  it isn't empty
  21.   then
  22.     echo "text found"    
  23.     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'`
  24.     echo "$entrydate"
  25.     # Command to make a new DayOne entry
  26.     dayone2 -j Journal -t supernote "machine transcription" -d "$entrydate" new < "$JOURNAL_PATH"/temp_output.txt
  27.     # Log this filename so it won't be added to DayOne again
  28.     echo "$filename" >> "$LOG_PATH"
  29.   else
  30.     # The supernote-tool command did not produce an output file, or it produced an empty file
  31.     echo "no text found"
  32.   fi
  33.   # remove the supernote-tool output file
  34.   rm "$JOURNAL_PATH"/temp_output.txt
  35. fi
  36. done
  37.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement