Skip to content

Instantly share code, notes, and snippets.

@Rust1667
Last active November 10, 2024 09:38
Show Gist options
  • Save Rust1667/c781cffed9653e4dd1f1b6b0330655eb to your computer and use it in GitHub Desktop.
Save Rust1667/c781cffed9653e4dd1f1b6b0330655eb to your computer and use it in GitHub Desktop.
Python script used to combine all the .md files inside a folder into 1, adding the title of the file at the beginning of each of the joined sections. This script must be place inside that folder with the .md files.
outputFileName = 'single-page2'
import glob
filenames = glob.glob('*.md')
with open(outputFileName, 'w') as outfile:
for fname in filenames:
with open(fname) as infile:
fileTitleString = "\n\n\n" + "# " + fname + "\n"
outfile.write(fileTitleString)
for line in infile:
outfile.write(line)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment