Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer

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: *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> //srvA/g$/Eng_Support/Data_Removal Use of uninitialized value in printf at C:\Scripts\ +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.


Log In?

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

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (6)
As of 2022-01-18 11:44 GMT
Find Nodes?
    Voting Booth?
    In 2022, my preferred method to securely store passwords is:

    Results (53 votes). Check out past polls.