os.walk function
import os
rootDir = 'test_dir'
numberOfFiles = 0
for root, dirs, files in os.walk(rootDir):
numberOfFiles += len(files)
print(numberOfFiles)
import os
rootDir = 'test_dir'
numberOfFiles = 0
for root, dirs, files in os.walk(rootDir):
numberOfFiles += len(files)
print(numberOfFiles)
Leave a Comment
Cancel reply