blackadder has asked for the wisdom of the Perl Monks concerning the following question:
use strict; use Win32::OLE qw[in with]; my $fs = Win32::OLE->CreateObject('Scripting.FileSystemObject'); my $fCount =0; my $sCount =0; my $size = 0; my $d = $fs->GetFolder("$ARGV[0]"); my @folders = $fs->GetFolder("$ARGV[0]" ); eval { $size = $d->size( ); while( @folders ) { my $folder = pop @folders; $fCount += $folder->Files->Count; $sCount += $folder->SubFolders->Count; for my $subFolder ( in $folder->SubFolders ) { $fCount += $subFolder->Files->Count; push @folders, $_ for in $subFolder->SubFolders ; $sCount += $subFolder->SubFolders->Count; } } my $size_gb = ($size/1024/1024); print "Size: ".$size_gb."Mb ($size byte), Files: $fCount, folders: + $sCount"; };
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: OLE dir size and number of files and folders
by particle (Vicar) on Oct 04, 2003 at 02:53 UTC | |
by blackadder (Hermit) on Oct 04, 2003 at 11:19 UTC |