Answers for "python find file in directory and subdirectories"

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
0

python find directory of file

import os
  
print('File name :    ', os.path.basename(__file__))
print('Directory Name:     ', os.path.dirname(__file__))
Posted by: Guest on January-10-2022

Code answers related to "python find file in directory and subdirectories"

Python Answers by Framework

Browse Popular Code Answers by Language