Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #75856

Re: Test for an empty directory that could be very large if it is not empty?

From John Gordon <gordon@panix.com>
Newsgroups comp.lang.python
Subject Re: Test for an empty directory that could be very large if it is not empty?
Date 2014-08-07 20:15 +0000
Organization PANIX Public Access Internet and UNIX, NYC
Message-ID <ls0mp5$djf$1@reader1.panix.com> (permalink)
References <mailman.12711.1407363468.18130.python-list@python.org>

Show all headers | View raw


In <mailman.12711.1407363468.18130.python-list@python.org> Virgil Stokes <vs@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
gordon@panix.com    watch 'House', or a real serial killer to watch 'Dexter'.

Back to comp.lang.python | Previous | NextPrevious in thread | Find similar | Unroll thread


Thread

Test for an empty directory that could be very large if it is not empty? Virgil Stokes <vs@it.uu.se> - 2014-08-06 23:46 +0200
  Re: Test for an empty directory that could be very large if it is not   empty? Gregory Ewing <greg.ewing@canterbury.ac.nz> - 2014-08-07 18:14 +1200
    Re: Test for an empty directory that could be very large if it is not   empty? Cameron Simpson <cs@zip.com.au> - 2014-08-07 17:08 +1000
    Re: Test for an empty directory that could be very large if it is not   empty? Roy Smith <roy@panix.com> - 2014-08-07 07:54 -0400
      Re: Test for an empty directory that could be very large if it is not empty? Peter Otten <__peter__@web.de> - 2014-08-07 14:06 +0200
      Re: Test for an empty directory that could be very large if it is not empty? Tim Chase <python.list@tim.thechases.com> - 2014-08-07 07:05 -0500
        Re: Test for an empty directory that could be very large if it is not empty? Roy Smith <roy@panix.com> - 2014-08-07 08:19 -0400
          Re: Test for an empty directory that could be very large if it is not empty? Tim Chase <python.list@tim.thechases.com> - 2014-08-07 12:37 -0500
            Re: Test for an empty directory that could be very large if it is not empty? Roy Smith <roy@panix.com> - 2014-08-07 21:10 -0400
  Re: Test for an empty directory that could be very large if it is not empty? John Gordon <gordon@panix.com> - 2014-08-07 20:15 +0000

csiph-web