I want to create multiple folders within themselves. If I have 3 folder I want to make on my desktop nested within each other. I want create the directory 'C:/Users/User/Desktop/folder_a/folder_b/folder_c/' the way I currently do this is I call os.path.exists() and os.mkdir() multiple times. Is there a way to do this without having to call these multiple times?
import os
DIR = 'C:/Users/User/Desktop/folder_a/folder_b/folder_c/'
if not os.path.exists(DIR):
os.mkdir(DIR)
DIR = DIR + 'folder_b/'
if not os.path.exists(DIR):
os.mkdir(DIR)
DIR = DIR + 'folder_c/'
if not os.path.exists(DIR):
os.mkdir(DIR)