Last active
August 29, 2015 14:19
-
-
Save JackMorganNZ/7e3883b6ddcf86817a58 to your computer and use it in GitHub Desktop.
Python script for creating chapter folders and base files
This file contains hidden or 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 | |
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() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Updated to use HTML language code as suffix.