Ok, I've got something working. If anyone sees something horribly inefficient, please let me know. I'll look into Win32::DirSize if I see perf issues with this solution. Thanks.
#!/usr/bin/perl -l use strict; use warnings; use File::Find; @ARGV=grep {-d or !warn "'$_': not a directory!\n"} @ARGV; die "Usage: $0 <dir> [<dirs>]\n" unless @ARGV; opendir(DIR1, $ARGV[0]); my @subdirs = grep { !/^\.\.?$/ } readdir(DIR1); closedir(DIR1); my ($tot,$n,$f,$dcount,$fcount,$totfull)=(0,0,0,0,0,0); for (@subdirs) { $_ = $ARGV[0] . "/" . $_; if (-f) { $f++; $totfull += -s; #print $_; } elsif (-d) { $dcount = 0; $fcount = 0; $tot = 0; find { no_chdir => 1, wanted => sub { #return unless -f; if (-d) {$n++; $dcount++;} elsif (-f) { $f++; $fcount++; #print "$f\n"; $tot += -s; $totfull += -s; #($max,$maxsz)=($_,$sz) if $sz >= $maxsz; } } }, $_; die "Found 0 files\n" unless $f; $dcount--; print <<"EOF"; Total files found in $_ : $fcount Total directories found in $_ : $dcount Total size: $tot EOF } } print <<"EOF"; ==================================== Directory Stats for $ARGV[0] ==================================== Total files found in $ARGV[0] : $f Total directories found in $ARGV[0] : $n Total size: $totfull EOF

In reply to Re: Mimic SC-DiskInfo with PERL by msensay
in thread Mimic SC-DiskInfo with PERL by msensay

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.