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')]