Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

How to count the number of files in a directory using Python

import os, os.path

# simple version for working with CWD
print len([name for name in os.listdir('.') if os.path.isfile(name)])

# path joining version for other paths
DIR = '/tmp'
print len([name for name in os.listdir(DIR) if os.path.isfile(os.path.join(DIR, name))])
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #How #count #number #files #directory #Python
ADD COMMENT
Topic
Name
1+6 =