Page 1 of 1

Directory statistics

Posted: Sun Nov 30, 2003 10:29 am
by jwb
I hate "asking" for code, but I need some help. I'm considerably rusty on my PHP skills and would like to do this with a decent method.

Basically, I'd like to get statistics for subdirectores in a tree of directories (horribly explained.) Including the total size, the filecount, and possibly the oldest/newest file. For example...

/home/*/.maildir/Spam/
where * is each subdir in /home/
(To generate spam statistics)

I have an idea of the basic function of doing this, but can't put it all together. If anyone could lend assistance, it'd be mucho appreciated. Thanks.

Posted: Sun Nov 30, 2003 11:27 am
by BDKR
I would say a combination of the dir directory class in a recursive function couple with some *nix commands like wc (if I'm not mistaken) and ls. Check out functions like stat(), filemtime() and fileatime(). scandir() would be nice, but it's P5 CVS so you may not want that.

1) I'm assuming you're using a *nix.
2) You can find info on dir at http://us2.php.net/manual/en/class.dir.php
3) If you don't know what a recursive function is, google or alltheweb.com can show you the light.

Cheerrs,
BDKR