Forum Moderators: coopster
I would very much appreciate it if someone could help with the following requirement.
An academic reference website of which I am administrator has literally thousands of images and text files. I need to know how many .txt files are in the various 2nd level folder sections. Each individual entry has 1 or 2 images plus thumbnails but only 1 txt file per entry, so a count of the txt files would give a more accurate "reading".
The folder structure is as follows (folder names changed for clarity):
- main folder
- historical period1
- lots of individual sub-folders of "regions", each folder containing numerous entries comprising of images, thumbnails and 1 txt file per entry. Some folders have more entries than others.
- historical period2
- lots of individual sub-folders of "regions", each folder containing numerous entries comprising of images, thumbnails and 1 txt file per entry. Some folders have more entries than others.
- historical period3
- lots of individual sub-folders of "regions", each folder containing numerous entries comprising of images, thumbnails and 1 txt file per entry. Some folders have more entries than others.
etc
So what I would need to find out using a little php script is the information
- Historical Period 1: .... txt files
- Historical Period 2: .... txt files
- Historical Period 3: .... txt files
etc.
I have managed to put together a little script but this needs the name of e.g. the region and I have so many regions it would take ages to keep changing it and running it.
Can anyone help ?
Many thanks from a newbie girly.
PHP has a great toolset for working with Directories [php.net]. And although you can recursively iterate directories with the functions found on those pages, the more advanced Standard PHP Library (SPL) [php.net] has built in iteration tools, one of them extended particularly for directory iteration.
$fc01 = count(glob("../Period_1/*/*.txt"));
echo "<b>"."Period_1:"."</b>"." $fc01\n"."<br>";
$fc02 = count(glob("../Period_2/*/*.txt"));
echo "<b>"."Period_1:"."</b>"." $fc02\n"."<br>";
etc for all the sections then adding them together for the final count. This "with a little help from my friends"..
I just got "PHP for Dummies" to get me started...