Skip to content

Instantly share code, notes, and snippets.

Created June 20, 2022 08:30
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save onewesong/68c7b1ebee0401c84e4bd38006abf2c1 to your computer and use it in GitHub Desktop.
#!/usr/bin/env python3
# coding: utf-8
import cson
def read_file(fp):
with open(fp) as f:
def write_file(fp, data):
with open(fp, 'w+') as f:
return f.write(data)
def convert(file):
d = cson.loads(read_file('notes/' + file))
if not d.get("content"):
output = '---\n'
title = d['title']
for char in '`[]':
if char in title:
title = "Unknown"
output += f"title: {title}\n"
output += f"updated: {d['updatedAt']}\n"
output += f"created: {d['createdAt']}\n"
output += '---\n\n'
output += d['content'].replace("(:storage/", "(../attachments/")
write_file('joplin/'+file.replace('.cson', '.md'), output)
if __name__ == '__main__':
import os
for file in os.listdir('notes'):
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment