Create folders within folders

27 views Asked by At

My code doesn't work, the intention was to create folders within folders.

import os

path = "D:\DOCS\Desktop"
n_folders = 100
x = 0
y = 0



os.chdir(path)
os.mkdir("Initial_Folder")

Second_Layer = []

while x < len(Second_Layer):
    while y < int(n_folders)+1:
        os.chdir(path + "\Initial_Folder")
        os.mkdir("\SecondLayer" + str(x))
        Second_Layer.append(x)
        y = y + 1
os.chdir(path + "\Initial_Folder"+"\SecondLayer" + str(x))
os.mkdir("\ThirdLayer" + str(y))
x = x + 1
0

There are 0 answers