in reply to How do I recursively count file sizes in a
script that works under both Windows and Linux?
Crulxuse strict; my $dir = '.'; print &dir_tree_size($dir) . "\n"; exit 0; 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 $i) { $total += dir_tree_size($dir . "/$i") } else { $total += -s $i} } return $total; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Answer: How do I recursively count file sizes in a script that works under both Windows and Linux?
by Anonymous Monk on Sep 12, 2001 at 12:34 UTC | |
|
RE: Answer: How do I recursively count file sizes in a script that works under both Windows and Linux?
by Anonymous Monk on Aug 31, 2000 at 22:09 UTC |