- Trending Categories
- Data Structure
- Operating System
- C Programming
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to scan through a directory recursively in Python?
You can use the os.walk function to walk through the directory tree in python.
import os for dirpath, dirs, files in os.walk("./my_directory/"): for filename in files: fname = os.path.join(dirpath,filename) with open(fname) as myfile: print(myfile.read())
The above program recursively moves through the my_directory tree and prints contents of each file in the tree to the console output.
- How to create a directory recursively using Python?
- How to remove a directory recursively using Python?
- How to create a Directory recursively using Java?
- Java program to List all files in a directory recursively
- How to scan a string for specific characters in Python?
- How to zip a folder recursively using Python?
- How to recursively iterate a nested Python dictionary?
- Java program to delete all the files in a directory recursively (only files)
- How to create a directory using Python?
- How to remove a directory using Python?
- How to delete a Python directory effectively?
- How to iterate through a dictionary in Python?
- How to iterate through a list in Python?
- How to iterate through a tuple in Python?
- How to check if a given directory contains any other directory in Python?