contentsフォルダのmdファイルを一覧取得してwikiリンク記法で保存する
code:getArticleTitle.py
#getArticleTitle.py
import os
contentsPath = "./contents/"
folders = os.listdir(contentsPath)
files_dir = sorted(f for f in folders if os.path.isdir((os.path.join(contentsPath, f))))
tempbody = []
for year in files_dir:
if year == ".git":
continue
tempbody.append("### " + year + "\n")
files = os.listdir(contentsPath + year)
for file in files:
if file == ".DS_Store":
continue
tempbody.append("[+ file.replace(".md","") + "]")
else:
tempbody.append("")
contentsListPath = "./contentlist.md"
with open(contentsListPath,mode="w") as f:
f.write("\n".join(tempbody))