python loop through all folders and subfolders

Solutions on MaxInterview for python loop through all folders and subfolders by the best coders in the world

showing results for - "python loop through all folders and subfolders"
Selma
30 Mar 2017
1directory = "c:\\folder\\you\\want\\to\\work_on"
2
3for root, subdirectories, files in os.walk(directory):
4    for subdirectory in subdirectories:
5        print(os.path.join(root, subdirectory))
6    for file in files:
7        print(os.path.join(root, file))
queries leading to this page
loop throug subfolder pythonpython loop through all folders in directoryiterate over folders pythonpython iterate all subfolders pathpython loop through all files in directory and subdirectoriesiterate over folders in directory pythonhow to loop through subdirectories with pythonpython program to traverse through all directory and subdirectorieshow to loop over folders in a folder pythoniterate through subdirectories pythoniterate folders and subfolders pythonloop through all folders in directory pythonpython iterate all subfoldershow to go through every sub folder in a folder with pythonpython loop through nested directoryloop over folders pythonloop through files in subfolders pythonloop through contets of all folders pytohnpython iterate through all foldersiterate through folders pythonpython os loop through subfolderspython go over all files in a directorypython loop through files in directory and subdirectorieshow to loop over directories and subdirectories pythonloop through folders in folder in pythonhow to loop through folders in pythonpython loop through folders and subfolderspython iterate through folders and subfoldersiteration over all dirs in dir pythonpython loop over all folders in directoryhow to loop throughfolder in folder pythonpython how to loop through foldersiterate through all folders in a directory pythonhow to iterate every sub folders in folder in pythoniterate through subfolders os pythonloop through folders in a directory pythonpython loop through all folders and subfolderspython loop through all folders in directroyiterate over folders in folder pythonpython go over every subfolder in a folderiterate through folders and subfolders pythonpython iterate over subfolderspython loop through directory and subdirectoriesiterate through all subdirectories pythonhow to go through subfolder pythonloop through all folders in a directory pythonpython 3 loop through folders and subfolderspython iterate over all filles in folder and subfolderiterate all folders in directory pythonfor each subdirectory pythoniterate over folders in pythonpython loop through all folders and subfolders