in reply to How to tell if a Directory is Empty

You can also use stat. Not sure about other platforms, but on my linux box, (stat "dirname")[7] == 48 indicates an empty dir.

Replies are listed 'Best First'.
Re^2: How to tell if a Directory is Empty
by afoken (Chancellor) on Oct 29, 2011 at 10:13 UTC
    on my linux box, (stat "dirname")[7] == 48 indicates an empty dir

    Very unreliable. That depends on the filesystem, on the filesystem options, and on the history of the directory. On my linux box with an old but large ext3 filesystem, most directories report a size of 4096, even freshly created ones. Only directorys that once had several hundred files grow larger, and they keep their larger size even when all files are removed.

    Alexander

    --
    Today I will gladly share my knowledge and experience, for there are no sweeter words than "I told you so". ;-)