'/path/to/some/directory';
sub determine_size {
if ( -f $File::Find::name ) {
$size += ( stat $File::Find::name )[7];
}
}
You don't have to stat the same file twice:
sub determine_size {
if ( -f ) {
$size += -s _;
}
}
find( \&determine_size, $
-f $File::Find::name ) {
$size += ( stat $File::Find::name )[7];
}
}
find( \&determine_size, $directory );
$size /= 1024 * 1024;
print "Total size: $size MB\n";
=cut
Relevant documents to read:
`perldoc File::Find` - http://perldoc.perl.org/File/Find.html
`perldoc -f stat`
- Original Message -
From: "Alan Haggai Alavi"
To: ; "Mike Blezien"
Sent: Wednesday, October 27, 2010 8:13 PM
Subject: Re: Directory Size
On Thursday 28 Oct 2010 06:30:01 Mike Blezien wrote:
Hello,
I've been out of the programming game for a while and re
- Original Message -
From: "Owen"
To: "Mike Blezien"
Cc: "Perl List"
Sent: Wednesday, October 27, 2010 8:17 PM
Subject: Re: Directory Size
Hello,
I've been out of the programming game for a while and recently got
back into
some small programmin
> Hello,
>
> I've been out of the programming game for a while and recently got
> back into
> some small programming projects. Just need to figure out if there is a
> Perl
> function to determine the total size of a folder and files? Meaning
> once we
> open/read a directory is to calculate the tot
Hello,
I've been out of the programming game for a while and recently got back into
some small programming projects. Just need to figure out if there is a Perl
function to determine the total size of a folder and files? Meaning once we
open/read a directory is to calculate the total, in MB's,
Nick wrote:
> Hi All,
Hello,
> Is there a way to get an entire directory and all sub-files/folders size
> in Perl? Basicly, I need the Perl version of "du -s".
http://ppt.perl.org/commands/du/index.html
John
--
use Perl;
program
fulfillment
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For a
On Sun, 28 Aug 2005 18:25:43 +0100
Nick <[EMAIL PROTECTED]> wrote:
> Hi All,
>
> Is there a way to get an entire directory and all sub-files/folders size
> in Perl? Basicly, I need the Perl version of "du -s".
>
> I've currently done it with stat but
> -Original Message-
> From: Nick [mailto:[EMAIL PROTECTED]
> Sent: Sunday, August 28, 2005 1:26 PM
> To: Perl Beginners
> Subject: Directory Size
>
> Hi All,
>
> Is there a way to get an entire directory and all
> sub-files/folders size in Perl? Basic
Hi All,
Is there a way to get an entire directory and all sub-files/folders size
in Perl? Basicly, I need the Perl version of "du -s".
I've currently done it with stat but this only gives a directory size
not taking into consideration everything inside it.
Nick
--
To unsu
You can do this with Net::FTP, but you'll have to write your own recursive
subroutine to get the subfolders...
-Original Message-
From: Paul Kraus [mailto:[EMAIL PROTECTED]
Sent: Monday, June 16, 2003 8:09 AM
To: [EMAIL PROTECTED]
Subject: Maybe OFF Topic - FTP Directory Size
Is their any Linux tools I can use to attach to an ftp site. Go to a
folder and then get the file size of everything in or beneath the
selected folder?
If I can do this perl even better. If not any point in the right
direction would useful.
Paul
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For
Dan Cox <[EMAIL PROTECTED]> wrote:
> How do you get a directory's size?
-s $dir;
But if you want disk usage, count blocks instead of bytes
and use File::Find to recurse.
use File::Find;
my $BLOCK_SIZE = 512;
my $total = 0;
sub wanted {
$total += (lstat)[12]*$BLOCK_S
How do you get a directory's size? Thanks for the help.
Dan Cox
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
14 matches
Mail list logo