While I agree with the answer provided by @DanielStutzbach: os.listdir()
will be slightly more efficient than using glob.glob
.
However, an extra precision, if you do want to count the number of specific files in folder, you want to use len(glob.glob())
. For instance if you were to count all the pdfs in a folder you want to use:
pdfCounter = len(glob.glob1(myPath,"*.pdf"))