IT Community - Software Programming, Web Development and Technical Support

Directory Size

This is a discussion on Directory Size within the PHP Programming forums, part of the Web Development category; well i want to get the total size of a directory, ive managed to get this code HTML Code: to ...


Go Back   IT Community - Software Programming, Web Development and Technical Support > Web Development > PHP Programming

Register FAQ Members List Calendar Mark Forums Read
  #1 (permalink)  
Old 02-24-2007, 01:04 AM
pranky pranky is offline
D-Web Programmer
 
Join Date: Feb 2007
Posts: 51
pranky is on a distinguished road
Default Directory Size

well i want to get the total size of a directory, ive managed to get this code
HTML Code:
to display the file size of every file in the directory
[php]
PHP Code:
<?php

$dir = "../demo/themes/";
        $tree = array();
        $dirs = array(array($dir, &$tree));
       
        for($i = 0; $i < count($dirs); ++$i)
        {
                $d = opendir($dirs[$i][0]);
                $tier =& $dirs[$i][1];

                while($file = readdir($d))
                {
                        if ($file != '.' and $file != '..')
                        {
                                $path = $dirs[$i][0] . DIRECTORY_SEPARATOR . $file;
                                if (is_dir($path))
                                {
                                        $tier[$file] = array();
                                        $dirs[] = array($path, &$tier[$file]);
                                }
                                else
                                {
                                        
                                    $size2 = filesize($path);
                                    $size = array($size2);
                                    print_r($size);
                                    echo "<br>";    
                                        
                                }    
                                                                                 
                        }
                        
                }
                
        }[/php]
the only problem is adding all them together. my inital idea was to create a array that stores the file size in a new element then just create a loop that adds them all together. the only problem i have is every file size is stored in array element 0

HTML Code:

Array ( [0] => 0 )
Array ( [0] => 881 )
Array ( [0] => 97 )
Array ( [0] => 970 )
Array ( [0] => 1246 )
Array ( [0] => 0 )
Array ( [0] => 123 )
Array ( [0] => 1678 )
Array ( [0] => 1661 )
Array ( [0] => 2184 )
Array ( [0] => 8689 )
All help is appreciated, thank you.
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 10-04-2008, 10:53 PM
jackjack jackjack is offline
D-Web Trainee
 
Join Date: Sep 2008
Posts: 12
jackjack is on a distinguished road
Default Re: Directory Size

MDS reports space used on your local and network drives.

* Quickly identify where space is used.
* Export results to HTML, Text and Excel.
* Sort results by Size or Name

jack

_______________________________

fear of flying cowboy boots
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Actove Directory Sundaram VB.NET Programming 1 02-25-2008 07:40 AM
size of object repository,size,object,repository,QTP itbarota Testing Tools 4 08-17-2007 03:43 AM
How can I create a virtual directory (or map virtual directory) for my website in TFS kingmaker ASP and ASP.NET Programming 1 07-27-2007 06:34 AM
how can we know the size of the object repository? itbarota Testing Tools 1 07-27-2007 05:57 AM
Why aren't my frames the exact size I specified? oxygen HTML, CSS and Javascript Coding Techniques 1 07-27-2007 03:50 AM


All times are GMT -7. The time now is 12:40 PM.


Copyright ©2004 - 2007, DiscussWeb. All Rights Reserved.

SEO by vBSEO 3.0.0