Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re: size of directory

by mikeirw (Pilgrim)
on Oct 10, 2002 at 07:08 UTC ( #204109=note: print w/replies, xml ) Need Help??


in reply to size of directory

If you're wanting to sum the sizes of all files within a directory, this should do it:

my $dir = '/path/to/dir'; my $dir_size = 0; my $file; opendir DIR, $dir or die "Unable to open $dir: $!\n"; $dir_size += -s "$dir/$file" while defined( $file = readdir DIR ); closedir DIR; print $dir_size;

This does not descend into subdirectories, though.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://204109]
help
Chatterbox?
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: (5)
As of 2020-02-18 22:34 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    What numbers are you going to focus on primarily in 2020?










    Results (80 votes). Check out past polls.

    Notices?