I'm trying to write a simple script that will return a count of files of a specific type in a folder. So far, I can get it to work for whatever folder I run it from, but I'm trying to find a way to alter it so I can drop it in a parent and return an individual count for each folder it looks at.
from pathlib import Path
import os
p = Path(Path.cwd())
p.glob('*')
files = list(p.glob('*.txt'))
number_files = len(files)
print(number_files)
exit = (input('Press any key to exit'))
This is what I've got so far. I know it works where it is because I'm pulling the current working directory, but I wanted to leave it flexible enough that I can drop it into wherever I need it and just change the filetype it's counting as I need to.