in reply to OLE dir size and number of files and folders

drop ole and use File::Find::Rule (a fine module, and platform independent!)

#!/usr/bin/perl use strict; use warnings; use File::Find::Rule (); die 'usage: dir_size.pl *directory*' unless 1 == @ARGV; my( $size, $files, $folders ); my $rule= File::Find::Rule->start( @ARGV ); while( my $item= $rule->match ) { next if $ARGV[0] eq $item; $size+= -s $item; -f $item and $files++; -d $item and $folders++; } printf "Size: %fMb (%d byte), Files: %d, folders: %d\n" => $size / 1024**2, $size, $files, $folders;

~Particle *accelerates*

Replies are listed 'Best First'.
Re: Re: OLE dir size and number of files and folders
by blackadder (Hermit) on Oct 04, 2003 at 11:19 UTC
    The code works fine on local dirs, however when assigning a remote folder to ARGV, I get the following error;
    C:\Scripts>size_file_test3.pl //srvA/g$/Eng_Support/Data_Removal Use of uninitialized value in printf at C:\Scripts\size_file_test3.pl +line 20. Size: 1.414590Mb (1483305 byte), Files: 3, folders:
    And the value of the folders is incorrect (always zero). I would appreciate it if you could guide me to fixing this problem now I am close to solving my issues.

    Thanks for this Mr Particle.

    Blackadder