forked from jackyzha0/quartz
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcreate_mod_times.py
More file actions
22 lines (18 loc) · 844 Bytes
/
create_mod_times.py
File metadata and controls
22 lines (18 loc) · 844 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
import os
from datetime import datetime
def create_mod_times_file(directory):
mod_times = {}
for root, dirs, files in os.walk(directory):
for file in files:
if file.endswith('.md'):
file_path = os.path.join(root, file)
mod_time = os.path.getmtime(file_path)
date_str = datetime.fromtimestamp(mod_time).strftime('%Y-%m-%d')
rel_path = os.path.relpath(file_path, directory)
mod_times[rel_path] = date_str
with open('mod_times.txt', 'w', encoding='utf-8') as f:
for path, date in mod_times.items():
f.write(f"{path}|{date}\n")
print("Created mod_times.txt with last modified dates")
# Replace 'path/to/your/content/directory' with the actual path to your content directory
create_mod_times_file('./content')