I need to count the number of files in a directory using Python.

I guess the easiest way is len(glob.glob('*')), but that also counts the directory itself as a file.

Is there any way to count only the files in a directory?

28 Answers
28

Leave a Reply

Your email address will not be published. Required fields are marked *