I have a root folder, say Z.
Inside Z, I have to create ten folders (say Q, W, E, R, T, Y, U, I, O, P, A). Further, I would like to make two folders (say M and N) in each of these ten folders
How can I solve this using Python ?
I have a root folder, say Z.
Inside Z, I have to create ten folders (say Q, W, E, R, T, Y, U, I, O, P, A). Further, I would like to make two folders (say M and N) in each of these ten folders
How can I solve this using Python ?
os.makedirs, will create all non-existant directories from a path and os.path.join will create a full path from arguments:
import os
root = '/tmp'
directories = ['Q', 'W', 'E', 'R', 'T', 'Y', 'U', 'I', 'O', 'P', 'A']
nestedDirectories = ['M', 'N']
for d in directories:
path = os.path.join(root, d, *nestedDirectories)
os.makedirs(path)
N folder nested in M, it's not what he want