How to get a list of filenames(without extension) in directory in python?

Viewed 18995

Assume my folder structure to be

+Data
  -abc.jpg
  -db.jpg
  -ap.jpg

Input is 'path/to/Data'

Expected output is ['abc','db','ap']

I saw many similar questions but did not get what exactly I wanted. I prefer to use os module in python.

6 Answers
import glob
import Path

for f in glob.glob("*.*"):
    print(Path(f).stem)
Related