On this page
article
Walk Directory Tree
Recursively list files in a folder.
Category: os
Problem
Recursively list files in a folder.
Solution
for root, dirs, files in os.walk("src"):
print(root, files)
Notes
- Adapt variable names and paths to your project
- Add error handling for production use
- See related chapters in the Learning Path