- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- 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?n
You can use the os.walk function to walk through the directory tree in python.
example
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.
- Related Articles
- How to scan through a directory recursively in Python?
- 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?
- Java program to delete all the files in a directory recursively (only files)
- How to recursively iterate a nested Python dictionary?
- How to zip a folder recursively using Python?
- How to check if a given directory contains any other directory in Python?
- How to create a directory using Python?
- How to remove a directory using Python?
- How to delete a Python directory effectively?
- How to rename multiple files recursively using Python?
- How to find if a directory exists in Python?
- How to use Glob() function to find files recursively in Python?

Advertisements