Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Re: OLE dir size and number of files and folders

by particle (Vicar)
on Oct 04, 2003 at 02:53 UTC ( #296456=note: print w/ replies, xml ) Need Help??


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*


Comment on Re: OLE dir size and number of files and folders
Download Code
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

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://296456]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (6)
As of 2015-07-02 23:36 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (47 votes), past polls