I am looking for a simple PHP script that will calculate the directory folder defined and then all sub folders under it.
I found one, however it doesn't display how I want. If it's possible to in the index.php define a folder size that will show the end user how much space they are using and then a % part to let them know how much of it there using. So basically it shows this as an example:
Total Size: 434 MB
Total Folders: 32
Total Files: 12345
Total % Used: 35%
So in the index.php I would define a total folder size in megabytes of how much they can use and it would calculate what % they have left. If that makes sense.
Thanks in advance!
|
Ambitious contributor
|
|
| 15Aug2011,08:13 | #2 |
|
You can use these functions I created to get the file count and folder count of a directory. I have not made one that gets the size of a directory but you would need to check every sub directory for file and if they exist get their size until every sub folder and all files have their size added together. Maybe my functions will help you out with your own implementation to solve this problem. Of course one function could get the file count, folder count, and total size. If I do solve this problem I'll post the solution as a single function that handles everything because it would be memory efficient to do the counting while I iterate once instead of calling multiple functions and running multiple loops. Hope this helps inspire you to finish what I started.
Folder Count PHP Code:
PHP Code:
PHP Code:
|
|
Ambitious contributor
|
|
| 16Aug2011,07:26 | #3 |
|
Instead of using those two functions just use this one function. It does not open all sub directories and get their folder and file counts. The other two where in accurate so I needed to use a better version that works. This has been tested to work and is accurate in both file and directory count. I'll try to fix it so it shows the whole file count including files in sub-directories and sub-directories. While the loop is at it I'll try to get it to show the total file sizes as well.
PHP Code:
Last edited by pein87; 16Aug2011 at 07:52.. |
