def create_dir(path, sub_dirs, label_dirs):
for sub_dir in sub_dirs:
for label_dir in label_dirs:
new_dir = os.path.join(path, sub_dir, label_dir)
Path(new_dir).mkdir(parents=True, exist_ok=True)
print(new_dir)
print('All directories created successfully!')
FOLDER_PATH = 'dataset/'
SUB_DIRS = ['train/', 'test/']
LABEL_DIR = ['dogs/', 'cats/']
create_dir(FOLDER_PATH, SUB_DIRS, LABEL_DIR)
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter