[Tutor] how to extract number of files from directory
alan.gauld at freenet.co.uk
Wed Oct 12 23:47:52 CEST 2005
> glob seems to be a good idea, ...
Yep, I got my glob and listdir mixed up earlier...
> it may be slower than glob, but i'm finding myself thinking more like...
> len([i for i in os.listdir('tmp') if i.lower().endswith('.jpg')])
> now, anyone with a solution for .jpg, .JPG, .jpeg, *and* .JPEG?
Sounds like a job for a regex?
More information about the Tutor