import os

def writeImpossible(directory, writeData):
    # For all roots, directories, and files in os.walk("story")
    # So all files and folders in os.walk
    for root, dirs, files in os.walk(directory, topdown=False):
        for name in files:
            # Print the file name and write the impossible data
            print(os.path.join(root, name))
            with(open(os.path.join(root, name), "w")) as f:
                f.writelines(impossibleData)
        for name in dirs:
            writeImpossible(directory + "\\" + name, writeData)
                            
    return 0
                            
                            
# Gets the template json and stores it in impossibleData
with (open("template.json")) as f:
    impossibleData = f.readlines()
    # Runs writeImpossible with the write data
    writeImpossible("advancement" , impossibleData)

print("\nFinished task.")
input()