I have this code:
# cwd = "C:\Users\johnr\Desktop\myFolder" - current working directory
for filename in os.listdir(os.path.join(cwd, "content")):
    header_file = open(header_file_dir, "r")
    footer_file = open(footer_file_dir, "r")
    if ".md" in filename:
        newFilename = filename.replace(".md", ".html")
    if ".tile" in filename:
        newFilename = filename.replace(".tile", ".html")
    elif ".html" in filename:
        newFilename = filename
    elif ".txt" in filename:
        newFilename = filename.replace(".txt", ".html")
    else:
        print(filename+" is not a valid file type!")
    currents_working_file = open(os.path.join(cwd, "build", newFilename), "w")
    # Write the header
    currents_working_file.write(header_file.read())
    # Get the actual stuff we want to put on the page
    text_content = open(os.path.join(cwd, "content", filename), "r")
    if ".md" in filename:
        text_cont1 = "\n"+markdown.markdown(text_content.read())+"\n"
    elif ".tile" in filename:
        text_cont1 = "\n"+textile.textile(text_content.read())+"\n"
    elif ".html" in filename:
        text_cont1 = text_content.read()
    elif ".txt" in filename:
        text_cont1 = text_content.read()
    else:
        print(filename+" is not a valid file type!")
    # Write the text content into the content template and onto the build file
    content_templ_dir = os.path.join(cwd, "templates", "content_page.html")
    if os.path.exists(content_templ_dir):
        content_templ_file = open(content_templ_dir, "r")
        content_templ_file1 = content_templ_file.read()
        content_templ_file2 = content_templ_file1.replace("{page_content}", text_cont1)
        currents_working_file.write(content_templ_file2)
    else:
        currents_working_file.write(text_cont1)
    # Write the footer to the build file
    currents_working_file.write("\n"+footer_file.read())
    # Close the build file
    currents_working_file.close()
which searches for a file in the 'content' directory and then creates a file of the same name in the'build' directory. How can I make this work when there are files in folders in the 'content' directory?