We use pathlib and forward slashes so that the Path() function can be used to automatically convert backslash to forward slash on Linux systems.
Does directory exist?
from pathlib import Path
if not Path('C:/MyDirectoryname').is_dir():
print("Does not exist")
Create Directory
from pathlib import Path
import os
if not Path('C:/MyDirectoryname').is_dir():
os.makedirs('C:/MyDirectoryname')
