Archive for November 2008

Making lots and lots of directories

November 21, 2008

I was testing how much space creating lots and lots of directories would take, and used this Python snippet:

for x in range(256):
    a = '%.02X' % x
    os.mkdir(a)
    for xx in range(256):
        b = '%.02X' % xx
        os.mkdir(os.path.join(a, b))

This creates 256 x 256 = 65536 folders, a top level of 00 to ff (in hex) and then in each top-level folder another 00 to ff.

Last time I made and deleted a truckload of folders and files my disk went wonky after a while, so for these I created a separate 10MB disk image using Disk Utility. (yes I use a Mac). If the DIsk Image uses DOS FAT as the filesystem, it runs out of space at 26/60, while the Mac OS filesystem runs out of space at E5/77.

Not sure what to make of these numbers at this point in time. If I Google long enough I could probably do the research to find exactly how much space each directory entry takes. Makes it abundantly clear that making lots of folders certainly doesn’t come for ‘free’. Must remember that  they also use space.

No point to make in doing this, just jotting down some notes for future reference.