Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > Get Directiry size in windows

Reply
Thread Tools

Get Directiry size in windows

 
 
warrenb101@hotmail.com
Guest
Posts: n/a
 
      09-05-2006
I'm trying to get the total directory size using perl. Here is a
snippet of what i've got now that doesn't work:

$dirsize = `dir C:\MyDirectory\somefolder . | findstr "File(s)"`;

print "$dirsize\n";


If I run the command from the command prompt it returns the correct
line (which i can later parse out to get the byte count.) but when I
run the perl script it returns results from the directory that the
script is run from not from what i specify in the command.

What am i doing wrong here? Or maybe there is a better way to do
it.....
I'd appreciate anyones help.
Thankx,
WarrenB

 
Reply With Quote
 
 
 
 
Dark
Guest
Posts: n/a
 
      09-06-2006
Win32:irSize (search.cpan.org is your friend). If you don't or can't
install modules try something like :

$dirsize = `dir \"C:\\Program Files\\\" | findstr \"File(s)\"`;

or

$dirsize = `dir \"C:/Program Files/\" | findstr \"File(s)\"`;

The bottom line is that backticks get interpolated just like double
quotes. I have escaped the other double quotes \" above. Hope it helps.


-I


http://www.velocityreviews.com/forums/(E-Mail Removed) wrote:
> I'm trying to get the total directory size using perl. Here is a
> snippet of what i've got now that doesn't work:
>
> $dirsize = `dir C:\MyDirectory\somefolder . | findstr "File(s)"`;
>
> print "$dirsize\n";
>
>
> If I run the command from the command prompt it returns the correct
> line (which i can later parse out to get the byte count.) but when I
> run the perl script it returns results from the directory that the
> script is run from not from what i specify in the command.
>
> What am i doing wrong here? Or maybe there is a better way to do
> it.....
> I'd appreciate anyones help.
> Thankx,
> WarrenB


 
Reply With Quote
 
 
 
 
Dark
Guest
Posts: n/a
 
      09-06-2006
Win32:irSize (search.cpan.org is your friend). If you don't or can't
install modules try something like :

$dirsize = `dir \"C:\\Program Files\\\" | findstr \"File(s)\"`;

or

$dirsize = `dir \"C:/Program Files/\" | findstr \"File(s)\"`;

The bottom line is that backticks get interpolated just like double
quotes. I have escaped the other double quotes \" above. Hope it helps.


-I


(E-Mail Removed) wrote:
> I'm trying to get the total directory size using perl. Here is a
> snippet of what i've got now that doesn't work:
>
> $dirsize = `dir C:\MyDirectory\somefolder . | findstr "File(s)"`;
>
> print "$dirsize\n";
>
>
> If I run the command from the command prompt it returns the correct
> line (which i can later parse out to get the byte count.) but when I
> run the perl script it returns results from the directory that the
> script is run from not from what i specify in the command.
>
> What am i doing wrong here? Or maybe there is a better way to do
> it.....
> I'd appreciate anyones help.
> Thankx,
> WarrenB


 
Reply With Quote
 
Paul Lalli
Guest
Posts: n/a
 
      09-06-2006
Dark wrote:
> $dirsize = `dir \"C:/Program Files/\" | findstr \"File(s)\"`;
>
> I have escaped the other double quotes \" above.


Yes, you have. Why have you?

Paul Lalli

 
Reply With Quote
 
warrenb101@hotmail.com
Guest
Posts: n/a
 
      09-06-2006
Thanks Dark!
Your solution works great.
I looked at Win32:irSize but the module wasn't available through the
windows perl package manager.

I appreciate the help,
warrenb



Dark wrote:
> Win32:irSize (search.cpan.org is your friend). If you don't or can't
> install modules try something like :
>
> $dirsize = `dir \"C:\\Program Files\\\" | findstr \"File(s)\"`;
>
> or
>
> $dirsize = `dir \"C:/Program Files/\" | findstr \"File(s)\"`;
>


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Image backup size - windows xp vs windows 7 Nomen Nescio Windows 64bit 4 12-30-2009 05:43 PM
how does size get passed into new( size ) ? Pallav singh C++ 2 04-07-2009 04:59 PM
Preferred Size, Minimum Size, Size Jason Cavett Java 5 05-25-2008 08:32 AM
mega pixels, file size, image size, and print size - Adobe Evangelists Frank ess Digital Photography 0 11-14-2006 05:08 PM



Advertisments