Guess I should search before I post.  Just found Win32::DirSize.  It is
MUCH faster than my previous code below and gives exactly what I need.

$Dir = "C:\\Windows";

print "\n\nGetting size of $Dir....";

my $Result = dir_size($Dir, my $DirInfo);

if ($Result == DS_RESULT_OK) {
        print "\tFiles Found = $DirInfo->{FileCount} \n";
        print "\tDirs Found = $DirInfo->{DirCount} \n";
        print "\tDir size = $DirInfo->{DirSize} bytes \n";
        print "\tDir size on disk = $DirInfo->{DirSizeOnDisk} bytes \n";
}

Dax

> I know how to get actual file size of a directory tree with Perl but can
> anyone offer assistance in getting actual disk space required or what
> windows calls "Size on Disk" of a directory tree.
>
> Below is what I have to find actual data size of a tree but it does not
> take into account wasted disk space due to cluster sizes.
>
> use File::Find;
> use File::stat;
>
> $GS_DiskSize;
>
> find({ wanted => \&GetDataSize}, ".");
>
> print "Data Size: $GS_DiskSize\n";
>
> sub GetDataSize {
>       $st = stat($File::Find::name) or die "No $file: $!";
>       $GS_DiskSize += $st->size;
> }
>
> Thanks,
>
> Dax
> _______________________________________________
> Perl-Win32-Users mailing list
> [email protected]
> To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
>

_______________________________________________
Perl-Win32-Users mailing list
[email protected]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to