CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Need a Custom or Prewritten Perl Program?: I need a program that...:
Total size of all files in directory?

 



Skorpion
Deleted

May 22, 2000, 11:09 AM

Post #1 of 2 (2143 views)
Total size of all files in directory? Can't Post

Is there a perl script that will allow you to enter a directory, and it will count the number of files, as well as their filesizes, then total it up for you? My web host doesn't have a very good control panel, and I'm wanting a quick way to see how much space I'm using out of my allotted 400MB.

Thanks much!

---Skorpion


monocle
User

May 22, 2000, 1:27 PM

Post #2 of 2 (2143 views)
Re: Total size of all files in directory? [In reply to] Can't Post

I grabbed this snippet of code from a free web site managing script. This code will calculate the number of kb a folder and all subfolders contains. You'll need to integrate it into your script. I don't know exactly what each line does but I know if you supply it with the path to teh directory ($path) it will provide the amount of space used ($used_space)
<BLOCKQUOTE><font size="1" face="Arial,Helvetica,sans serif">code:</font><HR>


$du = `du $path`;
$du =~ s/\n/ /g;
@terms = split(/\s+/,$du);
$size = @terms;
$used_space = ($terms[$size-2]/2);
</pre><HR></BLOCKQUOTE>

Hope this helps
Monocle

Hear techno music by Monocle at http://www.mp3.com/monocle

[This message has been edited by monocle (edited 05-22-2000).]

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives