SitePoint Sponsor

User Tag List

Results 1 to 2 of 2

Thread: Total dir size.

  1. #1
    SitePoint Enthusiast holev's Avatar
    Join Date
    Jul 2001
    Posts
    42
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Total dir size.

    well..
    i'm trying to find out the total size of all files in a certain folder..
    sort of like right-clicking it in windows and seeing..

    the folder has many sub-folders and more beeing added on the fly..
    now i made this code:
    PHP Code:
    <?
    $dir 
    opendir("/home/holevco/public_html/scs/");
    while (
    false !== ($file readdir($dir))) { 
        if (
    $file != "." && $file != "..") { 
            if(
    is_dir($file)) {
                
    $dirs[$file] = "1";
            }
        } 
    }
    while(list(
    $key$val) = each($dirs)) {
        
    $dir opendir("/home/holevco/public_html/scs/$key/");
        
    $i=0;
        while (
    false !== ($file readdir($dir))) {
            
    $i++;
               if (
    $file != "." && $file != "..") {
                
    $size[$i] =  filesize($file);
            }
        }
    }
    for(
    $i=0;$i<count($size);$i++) {
        echo 
    $size[$i] . "<br>";
        
    $totalsize $size[$i] + $totalsize;
    }
    ?>
    Total Size: <?=$totalsize?><br>
    the basic concept is..
    list whats in the main dir.. if its a dir.. add to an array
    then.. the array goes thru a loop that checks each dir and runs the funtion filesize() on every file there..
    this is the only way i thought of..
    and i tried doing it with the code attached...
    didnt work.

    help please.

  2. #2
    1-800-JMULDER JMulder's Avatar
    Join Date
    May 2001
    Location
    The Netherlands
    Posts
    1,745
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I think there's something similar at SourceForge.
    Jeroen Mulder

    w: www.jeroenmulder.com


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •