Created
April 29, 2019 06:14
-
-
Save forestbelton/809dfc0080fd025b881b382a61787421 to your computer and use it in GitHub Desktop.
Extract notes from Notes.app
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/bash | |
set -euxo pipefail | |
SQLITE=/Volumes/Macintosh\ HD/usr/bin/sqlite3 | |
XXD=/Volumes/Macintosh\ HD/usr/bin/xxd | |
GZIP=/Volumes/Macintosh\ HD/usr/bin/gzip | |
NOTES_DB=NoteStore.sqlite | |
"${SQLITE}" ${NOTES_DB} 'select quote(zdata) from zicnotedata where zdata is not null' > notes-raw.txt | |
awk -F\' '{print $2}' notes-raw.txt > notes-raw-stripped.txt | |
tr '[A-Z]' '[a-z]' < notes-raw-stripped.txt > notes-raw-stripped-lower.txt | |
NOTE_ID=1 | |
while read NOTE; do | |
NOTE_HEX=$(sed "${NOTE_ID}q;d" notes-raw-stripped-lower.txt) | |
echo ${NOTE_HEX} | "${XXD}" -r -p > note-${NOTE_ID}.gz | |
"${GZIP}" -d note-${NOTE_ID}.gz | |
NOTE_ID=$((NOTE_ID+1)) | |
done < notes-raw-stripped-lower.txt |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment