Skip to content

Instantly share code, notes, and snippets.

@JackMorganNZ
Last active August 29, 2015 14:19
Show Gist options
  • Select an option

  • Save JackMorganNZ/7e3883b6ddcf86817a58 to your computer and use it in GitHub Desktop.

Select an option

Save JackMorganNZ/7e3883b6ddcf86817a58 to your computer and use it in GitHub Desktop.
Python script for creating chapter folders and base files
import os
folders = ["algorithms",
"artificial_intelligence",
"complexity_tractability",
"coding_introduction",
"coding_compression",
"coding_encryption",
"coding_error_control",
"computer_graphics",
"computer_vision",
"data_representation",
"formal_languages",
"human_computer_interaction",
"introduction",
"network_communication_protocols",
"programming_languages",
"software_engineering"]
base_directory = "P:\\Git\\cs-field-guide\\text"
for folder in folders:
folder_directory = os.path.join(base_directory, folder)
if not os.path.exists(folder_directory):
os.makedirs(folder_directory)
filename = "{0}_en.md".format(folder)
filename_path = os.path.join(folder_directory, filename)
folder_file = open(filename_path, "w")
file_header = "# {0}\n".format(folder.replace('_', ' ').title())
folder_file.write(file_header)
folder_file.close()
@JackMorganNZ
Copy link
Copy Markdown
Author

Updated to use HTML language code as suffix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment