Thanks for pointing me in the right direction guys. I just finished the script (yeah it took me awhile, doing tech support sux0rs). Here is what I came up with, it's got some PM code in it along with mine. This was a quick hack to get it to do exctaly what I wanted, maybe the infinate wisdom of the Monks can clean it up some.
#!/usr/bin/perl use strict; use File::Find; my $dir = shift; if (!$dir) {die "perl $0 [startdir]\n";} my @subdirs = (); my $subdirsRef = \@subdirs; my %size; &get_sub_dirs($dir, $subdirsRef); for my $foo (@subdirs) { $size{$foo} = (&dir_tree_size($foo)); } print "Subdirectory size report for $dir\n\n\n"; foreach my $key (sort keys %size) { print "$key = "; printf("%.3f", $size{$key}); print " K\n"; } print "\n\n"; sub get_sub_dirs { my ($dir, $arrayRef) = @_; opendir DIR, $dir; my @files = grep !/^\.\.?$/, readdir DIR; for my $i (@files) { if (-d $i) { push @$arrayRef, $i; } } } sub dir_tree_size { my $dir = shift; my ($i,$total); $total = 0; opendir DIR, $dir; my @files = grep !/^\.\.?$/, readdir DIR; for $i (@files) { if(-d $dir . "\\" . $i) { $total += &dir_tree_size($dir . "\\$i") } else { $total += -s $dir . "\\" . $i} } $total = $total / 1024; return $total; }

In reply to Re: Find the size of sub dirs by roXet
in thread Find the size of sub dirs by roXet

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.