hola dudes, dudettes, others;
i know this is late, but
a wee scripty follows which actually does what
Concept99
wants. and a little more; filecounts, directory counts for the paths to be examined. remove to taste.
i use Adam Rich's Win32::DirSize because i gather from the
Concept99's posting's paths that we are on a Win32 system and also, incidentally, it is > 50% faster, does the formatting etc and more.
Concept99 need not read & reread mastering RegeXes,
admirable tho the book is, to parse a csv. is anything
simpler to parse than a csv of directory paths? well, yes,
i hope that none of the paths have commas in
them etc. but do i need a module to write a csv file? no sirree. perl is practical enough by itself. here goes:
use Win32::DirSize; # >= 50% faster than file::find
chomp(my @lines = (<DATA>));
my @pathsets = map { [ split ",", $_ ] } @lines;
my @dstats;
push @dstats,join ",",("Directory", "Size", "FileCount", "DirCount");
foreach my $pathset (@pathsets){
foreach my $path (@{$pathset}){
if (dir_size($path, my $dstat) == DS_RESULT_OK){
my $size = best_convert(my $unit,
$dstat->{HighSize},
$dstat->{LowSize});
my $fcnt = $dstat->{FileCount};
my $dcnt = $dstat->{DirCount};
push @dstats, join ",",($path, sprintf("%7.4f %s", $size, $uni
+t),$fcnt, $dcnt);
}
push @dstats, undef;
}
}
map { print } grep { defined } @dstats;
__DATA__
\\ooby\dooby$\stodge,\\ooby\ccc$\etc\lib
\\foo\bar$\wufnik,\\foo\bar$\id
which will spit out the results for each dir encountered.
hope it helps,
...wufnik
-- in the world of the mules there are no rules --
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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.