get a file with certain extension python code example
Example 1: how to search for a specific file extension with python
import glob, os
os.chdir("/mydir")
for file in glob.glob("*.txt"):
print(file)
Example 2: python get filename without extension
#Using pathlib in Python 3.4+
from pathlib import Path
Path('/root/dir/sub/file.ext').stem