Last active
May 2, 2022 19:09
-
-
Save imsakg/8f75a3bfd06242eb79829f2acc22bd0d to your computer and use it in GitHub Desktop.
Import markdowns to a markdown file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
from re import TEMPLATE | |
DIRs = sorted(os.listdir()) | |
FOLDERs = [] | |
FILEs = [] | |
PREFIX = ".md" | |
TEMPLATE = False | |
for dir in DIRs: | |
if os.path.isdir(dir): | |
FOLDERs.append(dir) | |
else: | |
if dir.endswith(PREFIX): | |
FILEs.append(dir) | |
for folder in FOLDERs: | |
DIR = sorted(os.listdir(folder)) | |
for file in DIR: | |
if file.endswith(PREFIX): | |
FILEs.append("{}/{}".format(folder, file)) | |
if TEMPLATE: | |
if "template.md" in DIRs: | |
pass | |
# TODO | |
else: | |
with open("main.md", "w") as f: | |
for file in FILEs: | |
with open(file, "r") as f2: | |
f.write(f2.read()) | |
f.write("\n") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment