Skip to content

Instantly share code, notes, and snippets.

@nhalstead
Created April 15, 2020 02:52
Show Gist options
  • Save nhalstead/d0804bab713f1a3b0875578accf1f465 to your computer and use it in GitHub Desktop.
Save nhalstead/d0804bab713f1a3b0875578accf1f465 to your computer and use it in GitHub Desktop.
GNotes to Joplin Import Format, This will convert a GNotes Export into a plain text import for Joplin.
#!/usr/bin/env python
import os
import sys
import time
dataIn = float(sys.stdin.read())
os.utime(sys.argv[1], (dataIn, dataIn))
#!/bin/bash
# Must be run in the folder containing the desired gnotes backup
BASE=/tmp/gnotes
rm -Rf $BASE
IFS=$'\n'
for N in `find ./ -maxdepth 1 -mindepth 1 -type d `
do
FOLDER=$N
mkdir -p $BASE/$FOLDER
echo "Scan: $N"
for SUB in `find $N/ -mindepth 1 -type d`
do
echo " Found ${SUB}"
TITLE=`sed 's/.*<p class="note_content">//;s/&amp;/a/g;s/&ensp;/ /g;s/&quot;/"/g;s/<br>/\n/g;s:</p>.*$::' $SUB/content.html | head -n1|sed 's#/#_#'`
TITLE=`echo $TITLE | tr -dc '[:alnum:]\n\r' | tr '[:upper:]' '[:lower:]'`
sed 's/.*<p class="note_content">//;s/&ensp;/ /g;s/&amp;/\&/g;s/&gt;/\>/g;s/&lt;/\</g;s/&quot;/"/g;s/<br>/\n/g;s:</p>.*$::' $SUB/content.html > $BASE/$FOLDER/$TITLE.txt
# Write Timestamp To File
cat $SUB/content.html | grep -Po '<input type="hidden" name="X-Modified-Date" value="([0-9]*)" \/>' | sed 's/[a-zA-Z\s\-\"\<\>\/\-\=\ \-]*//g' | cut -c -10 | ./convert_ts.py "$BASE/$FOLDER/$TITLE.txt"
echo "Written to ${N}/${SUB}"
# exit
done
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment