I am developing a website that is basically about saving paper by inserting the invoices that are normally printed in my company. I would like to have a cool counter to show how much paper we have saved! That is... Basically how many PDF files exist in my storage directories !
I have the following routes:
Oh my God! Look how much I have filtered the folders to divide the amount of PDF well, they are basically separated by an ID, then the name of the invoice and inside are the documents that can vary between 1 and 4.
The fact is that there are many folders that inside have many folders that again have MANY FOLDERS, I'm going crazy!
How do I find out HOW MANY PDF files exist in my folder:
"Uploads/live"
so that it takes into account ALL possible subfolders?
I've tried this but it doesn't take subfolders into account:
function contarArchivos ( $path, $extensionArchivo ) {
$matches = glob ( $path . "*." . $extensionArchivo );
$numDirectories = 0;
if ( $matches ) {
$numDirectories = count( $matches );
}
return $numDirectories;
}
I leave you a function that I tried and it works perfectly for me in +PHP5
This verifies each folder with .pdf files and at the end you return the Array with the total
If you then need to know the names of the files you can print the array
With that you can manage name and know how many files with "X" name there are.