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