Forum Moderators: coopster

Message Too Old, No Replies

Directory file count of unique named directories

         

DaggarJon

1:54 pm on Mar 20, 2009 (gmt 0)

10+ Year Member



I am trying to find a script that will count the files of specific directories.

this is my folder structure

-top folder 1
--sub folder a
--sub folder b
-top folder 1
--sub folder a
--sub folder b
-top folder 3
--sub folder 1
---sub folder a
---sub folder b
--sub folder a
--sub folder b
-top folder 4
--sub folder a
--sub folder b
ect...

all folder a's have the same name, and all folder b's have the same name. I want to be able to return a caluclated value divided by 2 of any and all folders named sub folder a. With the folders being located on different directory levels, i havent been able to get the desired results.

I found this little script:

<?php
function num_files($directory='.')
{
return count(glob($directory."/top folder 1/*/sub folder a/*"));
}
echo num_files();
?>

but it doesnt look to be counting the second level sub folder a. I should get a total count of 1232... well, 1233 if it counts the thumbs.db file, but if possible i would like that divided by 2 for the real count of 616. the script above returns a count of 917 (non divided)

thanks for any help :)

ogletree

7:43 pm on Mar 23, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Just set up some loops and if statements and use opendir() and readdir()