in reply to How do I count all the files in all subdirectories?

In general, it's intractable. There is no standard way to get an instantatnious snapshot, so you can't tell if you missed anything. Without knowing what was renamed to what, you don't know if a new name is one you already scanned or one you missed before.

That could be helped if you had some way to uniquely identify the directory other than its name. Say, some key file that never changes and never gets renamed itself.

You could have all the renamings and other changes go though an API that has hooks, or puts out a journal report, that your tools can use to know what's happening.

Some OS's will do that for you directly.

Some OS's have hooks or 3rd party tools to obtain a virtual "snapshot", meant for making consistant backups.

—John

  • Comment on Re: How do I count all the files in all subdirectories?