My problem is I want to make a list of how many files with a certain extension or names in a folder when there are a lot of different types of files in it.
For instance, let's say there are a bunch of different types of files in a folder and I only want to count how many jpg files there are.
I tried the code below from some other person's Q&A on stackoverflow and it does show all the names of jpg files in the folder but doesn't show the number of how many jpg files there are.
import glob, os
filelist = os.listdir('D:\Train')
for file in filelist:
if(file.endswith('jpg')):
print(file)
Also, I'd like to know if there's a way I can count the file with certain words in the names.
ex) count all the jpg files in the folder that contain 'fire' in their names (fire01.jpg, fire02.jpg, and so on)