Answers for "Find Files With a Certain Extension in the Directory and Its Subdirectories in Python"

0

Find Files With a Certain Extension in the Directory and Its Subdirectories in Python

>>> import pathlib
>>> fileDir = r"C:\Test"
>>> fileExt = r"**\*.txt"
>>> list(pathlib.Path(fileDir).glob(fileExt))
[WindowsPath('C:/Test/test.txt'), WindowsPath('C:/Test/test1.txt'), WindowsPath('C:/Test/sub/test1.txt')]
Posted by: Guest on May-26-2021

Code answers related to "Find Files With a Certain Extension in the Directory and Its Subdirectories in Python"

Python Answers by Framework

Browse Popular Code Answers by Language