In <mailman.12711.1407363468.18130.python-l...@python.org> Virgil Stokes 
<v...@it.uu.se> writes:

> Suppose I have a directory C:/Test that is either empty or contains more 
> than 2000000 files, all with the same extension (e.g. *.txt). How can I 
> determine if the directory is empty WITHOUT the generation of a list of 
> the file names in it (e.g. using os.listdir('C:/Test')) when it is not 
> empty?

Is it one directory that is sometimes empty and other times teeming with
files, or is it a series of directories which are created afresh and then
await arrival of the files?

If the latter, you could try looking at the size of the directory entry
itself.  On the system I'm writing from, a freshly-created directory is
4K in size, and will grow in 4K chunks as more and more files are created
within the directory.  However, the directory entry does not shrink when
files are removed.

--
John Gordon         Imagine what it must be like for a real medical doctor to
gor...@panix.com    watch 'House', or a real serial killer to watch 'Dexter'.


-- 
https://mail.python.org/mailman/listinfo/python-list

Reply via email to