I don't have File::Recurse module in my instalation (Active State build 629).
Is it something new in build 630 ?

Marko

12/21/01 8:54:25 PM, Chuck Lawhorn <[EMAIL PROTECTED]> wrote:

>There's a much easier way. I use this routine to get the number of files and size of 
>the folder.
>When the routine is done, $Files contains the number of files in the folder and 
>subfolders,
>$Folder containd the number of subfolders, and $DirSize contains the size of the 
>directory. These
>numbers match the information given if you right-click on the folder in Windows 
>Explorer and
>choose "Properties." There must be a Windows API that does it quicker, as the result 
>in
>WinExplorer is usually quite fast. This script takes some time if the folder is 
>large, but it is
>accurate.
>
>Hope this helps,
>
>--Chuck
>
>----------
>
>use File::Recurse;
>
>my( $Source, $DirSize, $Folders, $Files );
>
>$Source = (folder to check );
>recurse( \&SizeFiles, $Source );
>
>sub SizeFiles {
>  $DirSize += ( -s );
>  ( -d ) ? ++$Folders : ++$Files;
>}
>
>----------
>
>--- Marko Nikolic <[EMAIL PROTECTED]> wrote:
>> Hello,
>> 
>> try this, I use this sub in my scripts.
>> 
>> DirSize( $dir, \$size);
>> 
>> sub DirSize  {
>>     my ( $path, $dirSize ) = @_;
>>     my ( @dirContents, $name, $fileName );
>> 
>>     if ( -f $path )  { die "Not a directory !\n"; }
>> 
>>     opendir ( DIR, $path ) or die "Can't open directory $path !\n";
>>     @dirContents = grep (/[^\.]/, readdir(DIR));     # remove . i ..
>>      foreach $name (@dirContents)  {
>>                  $fileName = $path."\\".$name;
>> 
>>              # if it is file, add size, otherwise recursively call DirSize
>>              if (-f $fileName)  {
>>             ${$dirSize} = ${$dirSize} + (stat($fileName))[7];
>>         }
>>              else  { DirSize($fileName, \${$dirSize}); }
>>     }
>> }
>> 
>> 
>> 
>> 12/20/01 8:49:40 PM, "Satelle, StevenX" <[EMAIL PROTECTED]> wrote:
>> 
>> >A simple question (I hope!). Does anyone know how to get the size of a
>> >folder?
>> >
>> >Steven Satelle
>> >Tac
>> >i6064372
>
>
>__________________________________________________
>Do You Yahoo!?
>Send your FREE holiday greetings online!
>http://greetings.yahoo.com
>
>



_______________________________________________
Perl-Win32-Admin mailing list
[EMAIL PROTECTED]
http://listserv.ActiveState.com/mailman/listinfo/perl-win32-admin

Reply via email to