The following code allows me to create a directory if it does not already exist.
dir = \'path_to_my_folder\' if not os.path.exists(dir): os.makedirs(dir)
import os import shutil path = 'path_to_my_folder' if not os.path.exists(path): os.makedirs(path) else: shutil.rmtree(path) # Removes all the subdirectories! os.makedirs(path)
How about that? Take a look at shutil's Python library!
Python