Created
April 29, 2020 11:05
-
-
Save m000/d32f28ded1f19115e950c988b776a8d5 to your computer and use it in GitHub Desktop.
Export all your Laverna notes as markdown
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/env python3 | |
from pathlib import Path | |
import json | |
import os | |
if __name__ == '__main__': | |
root = Path('.') | |
notes = (root / 'notes').glob('*.json') | |
export = root / 'export' | |
export.mkdir(exist_ok=True) | |
for nf in notes: | |
note = json.loads(nf.read_text()) | |
notemd = None; notemd_idx = 0 | |
while notemd is None or notemd.exists(): | |
if notemd is None: | |
notemd = export / ('%s.md' % (note['title'])) | |
else: | |
notemd = export / ('%s_%02d.md' % (note['title'], notemd_idx)) | |
notemd_idx += 1 | |
notemd.write_text(note['content']) | |
ts = (note['updated']/1000,)*2 | |
os.utime(notemd, ts) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I had been using Laverna for a while. I had a few dozens of notes taken, but in the end I didn't stick with it. Cleaning up my Dropbox folder (where Laverna syncs), I found my old notes. I wrote this small script to export them to Markdown before cleaning up the folder. The script needs to be run inside the Laverna Dropbox app folder. I didn't care to preserve the notebook hierarchy, so the script doesn't process the contents of the
notebooks
folder.