Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 41125
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T15:07:53+00:00 2026-05-10T15:07:53+00:00

I’m looking for something that will show me the size of each folder within

  • 0

I’m looking for something that will show me the size of each folder within my main folder recursively.

This is a LAMP server with a CGI-Bin so most any PHP script should work or anything that will work in the CGI-Bin.

My hosting company does not provide an interface for me to see which folders are consuming the most amount of space. I don’t know of anything on the Internet and did a few searches however I came up with no results.

Something implementing graphs (GD/ImageMagick) would be best but not required.

My host supports only Perl in the CGI-BIN.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-10T15:07:53+00:00Added an answer on May 10, 2026 at 3:07 pm

    Strange, I came up on Google with many relevant results and this one is probably the most complete.

    The function ‘getDirectorySize’ will ignore link/shorcuts to files/directory. The function ‘sizeFormat’ will suffix the size with bytes,KB,MB or GB accordingly.

    Code

    function getDirectorySize($path) {   $totalsize = 0;   $totalcount = 0;   $dircount = 0;   if ($handle = opendir ($path))   {     while (false !== ($file = readdir($handle)))     {       $nextpath = $path . '/' . $file;       if ($file != '.' && $file != '..' && !is_link ($nextpath))       {         if (is_dir ($nextpath))         {           $dircount++;           $result = getDirectorySize($nextpath);           $totalsize += $result['size'];           $totalcount += $result['count'];           $dircount += $result['dircount'];         }         elseif (is_file ($nextpath))         {           $totalsize += filesize ($nextpath);           $totalcount++;         }       }     }   }   closedir ($handle);   $total['size'] = $totalsize;   $total['count'] = $totalcount;   $total['dircount'] = $dircount;   return $total; }  function sizeFormat($size) {     if($size<1024)     {         return $size.' bytes';     }     else if($size<(1024*1024))     {         $size=round($size/1024,1);         return $size.' KB';     }     else if($size<(1024*1024*1024))     {         $size=round($size/(1024*1024),1);         return $size.' MB';     }     else     {         $size=round($size/(1024*1024*1024),1);         return $size.' GB';     }  } 

    Usage

    $path='/httpd/html/pradeep/'; $ar=getDirectorySize($path);  echo '<h4>Details for the path : $path</h4>'; echo 'Total size : '.sizeFormat($ar['size']).'<br>'; echo 'No. of files : '.$ar['count'].'<br>'; echo 'No. of directories : '.$ar['dircount'].'<br>';  

    Output

    Details for the path : /httpd/html/pradeep/ Total size : 2.9 MB No. of files : 196 No. of directories : 20 
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 81k
  • Answers 81k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer You don't appear to use err in the rest of… May 11, 2026 at 4:32 pm
  • Editorial Team
    Editorial Team added an answer you really want to be mocking the results returned from… May 11, 2026 at 4:32 pm
  • Editorial Team
    Editorial Team added an answer The short answer is that including the Qt testlib causes… May 11, 2026 at 4:32 pm

Related Questions

I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti
I am currently running into a problem where an element is coming back from
Seemingly simple, but I cannot find anything relevant on the web. What is the
Configuring TinyMCE to allow for tags, based on a customer requirement. My config is
Is it possible to replace javascript w/ HTML if JavaScript is not enabled on

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.