Wrote this simple (messy) python script to convert Evernote html into markdown files. Using the new .md files on https://obsidian.md
from bs4 import BeautifulSoup
from mdutils import MdUtils
import glob
def convert(filename):
print('Converting: ' + filename)
output_name = filename.replace(
'.html', '').replace('origin/', 'converted/')
file = open(filename, "r").read()
soup = BeautifulSoup(file, 'html.parser')
# Title
title_tag = soup.find('meta', itemprop='title')
title = title_tag['content']
# Date
created_tag = soup.find('meta', itemprop='created')
created_string = created_tag['content']
year = created_string[0:4]
month = created_string[4:6]
day = created_string[6:8]
created = year + "-" + month + "-" + day
# Tags
tags_tag = soup.find_all(attrs={"itemprop": "tag"})
tags = ""
for tag_content in tags_tag:
tags = tags + " #" + tag_content['content']
# Body
body = soup.find(attrs={"class": "peso"})
mdFile = MdUtils(file_name=output_name)
mdFile.write('----')
mdFile.new_line("Created at: " + created)
mdFile.new_line("Tags:" + tags)
mdFile.new_paragraph(body.get_text("\n"))
mdFile.create_md_file()
for filename in glob.iglob("origin/" + '**/*.html', recursive=True):
convert(filename)