Many thanks Mark - a real compact one ! Something exactly I was looking for.
I am n't sure, instead of "stat" function we could use "-s <file_name>" (-s,
returns the number of bytes of the file size) operator, to reduce the
function call overhead ?!
  Also, wanted to let know, I found the re-direction of the "dir
<directory_name> /s" to an output file and then retrieving the total disk
usage of the directory from the o/p file to be atleast TWO times faster.
Used the pattern "files.*listed", which makes me think twice on portability
even within the different Windows machines.

Thanks a lot for all yours and David's precious time !

-Praveen


-----Original Message-----
From: Mark Goland [mailto:[EMAIL PROTECTED]]
Sent: Monday, 30 December 2002 2:00 PM
To: Rajendra Babu, Praveen
Cc: perl
Subject: Re: Directory and its sub-directory disk usage: Windows '98


unless you want to recurse the tree this will do it,

unless(opendir local $TMP,$ARGV[0] ){
 print "-------------invalid directory-------------\n";
 print "USAGE:\n\t\t$0 directory to parse";
 exit 1;
}

chomp (@FILES=`dir /s /b $ARGV[0]`);

for ( @FILES ){

( $Size+= (stat $_)[7] );

}

print "TOTAL SIZE: $Size bytes \n";


----- Original Message -----
From: "Rajendra Babu, Praveen" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Sunday, December 29, 2002 7:07 PM
Subject: Directory and its sub-directory disk usage: Windows '98


> Hi All,
>       This is in Windows '98. I am writing a script to find the entire
> directory space(i.e. including sub-directories) occupied from an input
> directory name.
>
> Eg. If at the command prompt  I give something like, "perl dir_size.pl
> h:\raps\test\prajendr", the output should be the entire disk space
occupied
> by the directory "prajendr" and all its sub-directories. The one least
> option I am looking at is "dir /s" and re-directing it to a file and then
> manipulating the same.
>
>   Is there a better way in Windows ?!
>
> TIA,
> Praveen
>
>
> IMPORTANT-
> (1) The contents of this email and its attachments are confidential and
> intended only for the individual or entity named above. Any unauthorised
> use of the contents is expressly prohibited.  If you receive this email
> in error, please contact us, then delete the email.
> (2) ACNielsen collects personal information to provide and market our
> services. For more information about use, disclosure and access see our
> privacy policy at <www.acnielsen.com.au> or contact us on
[EMAIL PROTECTED]
>
> --
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>

IMPORTANT-
(1) The contents of this email and its attachments are confidential and 
intended only for the individual or entity named above. Any unauthorised
use of the contents is expressly prohibited.  If you receive this email 
in error, please contact us, then delete the email.
(2) ACNielsen collects personal information to provide and market our 
services. For more information about use, disclosure and access see our 
privacy policy at <www.acnielsen.com.au> or contact us on 
[EMAIL PROTECTED]

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to