Filecount

Peter Hansen peter at engcorp.com
Tue Nov 13 20:39:11 EST 2001


Dumbledore wrote:
> 
> Is it possible to use a Jpython script to count files in a certain directory?
> If yes, how is the script look like?

>>> print len(filter(os.path.isfile, os.listdir('.')))
24

Only works in the current directory as written... note that
the list returned by listdir() doesn't include path information,
so you'd have to add that to improve it.

-- 
----------------------
Peter Hansen, P.Eng.
peter at engcorp.com



More information about the Python-list mailing list