Answers for "iterate through subdirectories python"

1

python loop through all folders and subfolders

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))
Posted by: Guest on December-25-2020
0

python loop through files in directory recursively

import os
rootdir = './path/to/files/'

for subdir, dirs, files in os.walk(rootdir):
    for file in files:
        print os.path.join(subdir, file)
Posted by: Guest on August-30-2020

Code answers related to "iterate through subdirectories python"

Python Answers by Framework

Browse Popular Code Answers by Language