Best way to quickly estimate the total number of files contained in a filesystem?
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Jeff_Skubick
Posted On:   Tuesday, July 23, 2002 06:05 PM

Given a directory specifier that represents the top of a mounted filesystem (ex: "C:" or "D:" for Windows, "/" for Linux, etc.), is there a fast, high-level way to get an estimate (not necessarily exact or particularly accurate) of the total number of files and/or directories (it doesn't really matter which) contained within it? I know there's always the brute force approach -- recursively parsing the directory tree and physically counting the number of files and directories found along the way, but the whole reason why I'm trying to estimate the number in the first place is so I can provide some kind of meaningful progress estimate while the REAL work -- recursively parsing the directory tree and looking for duplicate files --   More>>

Given a directory specifier that represents the top of a mounted filesystem (ex: "C:" or "D:" for Windows, "/" for Linux, etc.), is there a fast, high-level way to get an estimate (not necessarily exact or particularly accurate) of the total number of files and/or directories (it doesn't really matter which) contained within it?



I know there's always the brute force approach -- recursively parsing the directory tree and physically counting the number of files and directories found along the way, but the whole reason why I'm trying to estimate the number in the first place is so I can provide some kind of meaningful progress estimate while the REAL work -- recursively parsing the directory tree and looking for duplicate files -- slowly takes place.

   <<Less

Re: Best way to quickly estimate the total number of files contained in a filesystem?

Posted By:   Christopher_Koenigsberg  
Posted On:   Wednesday, July 24, 2002 01:02 PM

How would you propose to do your "estimate"?



One thing I could imagine would be, find the total size of the filesystem/partition, use some guess for the average size of files, and divide? (partition size / avg filesize = approx. num files)



But of course that would only be reasonable if you knew something about the kind of files involved, to get some reasonable guess about their average size.



And, depending on the minimum cluster size of the filesystem (the worst would be old FAT), lots of tiny files might use up extra space, and thus mess up your estimates...

About | Sitemap | Contact