52 lines
1.5 KiB
Python
52 lines
1.5 KiB
Python
"""
|
|
This script ensures that every daily note linked in the timestamped notes exists.
|
|
"""
|
|
import frontmatter
|
|
import io
|
|
import glob
|
|
from datetime import datetime
|
|
import os
|
|
|
|
timestamped_notes = glob.glob("timestamped/*.md")
|
|
|
|
daily_links = set()
|
|
for child in timestamped_notes:
|
|
with io.open(child, 'r') as file:
|
|
link = frontmatter.load(file).get('daily')
|
|
daily_links.add(link)
|
|
|
|
new_daily_names = set()
|
|
for link in daily_links:
|
|
base_name = link[2:-2]
|
|
path = f"periodic/daily/{base_name}.md"
|
|
if not os.path.exists(path):
|
|
new_daily_names.add(base_name)
|
|
|
|
print(new_daily_names)
|
|
|
|
# for name in new_daily_names:
|
|
# date = datetime.strptime(name, '%Y-%m-%d')
|
|
|
|
# with io.open(f"periodic/daily/{name}.md", 'x', encoding='utf8') as f:
|
|
# f.write(f"# {name}\n\n")
|
|
|
|
# post = frontmatter.load(f)
|
|
|
|
# post['id'] = name
|
|
# post['aliases'] = []
|
|
# post['title'] = name
|
|
# post['tags'] = [
|
|
# 'authorship/original',
|
|
# 'destiny/permanent',
|
|
# 'status/draft',
|
|
# 'type/periodic/daily'
|
|
# ]
|
|
# post['dg-publish'] = True
|
|
# post['date-created'] = datetime.now().strftime("%Y-%m-%dT%H:%M:%SZ")
|
|
# post['weekly'] = f'"[[{date.strftime('%Y-[W]%W')}]]"'
|
|
# post['monthly'] = f'"[[{date.strftime('%Y-%m')}]]"'
|
|
# post['quarterly'] = f'"[[{date.strftime('%Y-[Q]%q')}]]"'
|
|
# post['yearly'] = f'"[[{date.strftime('%Y')}]]"'
|
|
|
|
# frontmatter.dump(post, f)
|