Skip to content

Instantly share code, notes, and snippets.

@JackMorganNZ
Last active August 29, 2015 14:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JackMorganNZ/7e3883b6ddcf86817a58 to your computer and use it in GitHub Desktop.
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
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