Using os.makedirs and os.path.join

Can someone please explain to me how the os.makedirs and os.path.join are used to create directories and subdirectories

1 Like

Use os.path.join to specify the location to create using os.makedirs. makedirs will create missing parent directories if absent.

Why would I not use os.makedirs to create the six required directories and skip os.path.join?

The method create_train_val_dirs expects you to create the expected directory structure. How you do it doesn’t matter.

OK, so I created training and validation, each attached to the root directory, then added cats and dogs to each. But I’m not getting the expected output.
Would you be able to look at my code? I’d like to be able to get on to the rest of the assignment.

1 Like

this is what my root directory looks like:


root_dir
training
cats
dogs
validation
cats
dogs
sample_data

Please read the documentation for both methods and use the apis correctly.
Invoke os.makedirs with the path to be created. Use os.path.join to create the path from a parent directory to a child directory.