How do I read the number of files in a folder using Python?

Viewed 45856

How do I read the number of files in a specific folder using Python? Example code would be awesome!

6 Answers

recursive solution:

sum(len(fs) for _,_,fs in os.walk(os.getcwd()))

for current directory solution:

len(os.walk(os.getcwd()).next()[2])
Related