directory = "c:\\folder\\you\\want\\to\\work_on" for root, subdirectories, files in os.walk(directory): for subdirectory in subdirectories: print(os.path.join(root, subdirectory)) for file in files: print(os.path.join(root, file))
Here is what the above code is Doing:
1. It’s looping through the directory and all of its subdirectories.
2. It’s printing out the names of all the subdirectories.
3. It’s printing out the names of all the files.