How To Search For Files Recursively In Python
Jul 5, 2022
The aim of this page📝 is to share how I am getting all files that contain migration
and that are spread across multiple subdirectories of a particular repository.
1. NOTES
- use glob module from the standard library
- use
glob
method of the module - use
**
for any char in multiple folders - use
*
for any char in a single folder - pass
recursive=True
as a second argument - return the match
import glob
def get_migration_files():
files = glob.glob("./**/migration*.py", recursive=True)
return files