FiReWaLL has asked for the wisdom of the Perl Monks concerning the following question: ⭐ (directories)
It should return the total size of all the tree. In Windows, it works, but in Linux, it doesn't. It returns only the current directory file sizes. What should I do?$directory = '/thedir/thatiwantto/count'; print "\n\n"; print CountSize($directory); print "\n\n"; sub CountSize { my ($directory) = $_[0]; my ($ask, $filesize, $item, $size, @raiz); @raiz = glob("$directory/*.*") || warn(); foreach $item (@raiz) { $ask = -d $item; if ($ask) { $size += &CountSize($item); } else { $size += -s $item; } } return($size); }
Originally posted as a Categorized Question.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: How do I recursively count file sizes in a script that works under both Windows and Linux?⭐
by tachyon (Chancellor) on Mar 19, 2002 at 14:43 UTC | |
|
Re: How do I recursively count file sizes in a script that works under both Windows and Linux?
by Crulx (Monk) on Jan 22, 2000 at 01:28 UTC | |
by Anonymous Monk on Sep 12, 2001 at 12:34 UTC | |
by Anonymous Monk on Aug 31, 2000 at 22:09 UTC | |
|
Re: How do I recursively count file sizes in a script that works under both Windows and Linux?
by Anonymous Monk on Mar 19, 2002 at 10:19 UTC |