develooper Front page | perl.perl6.users | Postings from October 2022

Re: folder size

Thread Previous | Thread Next
From:
Bruce Gray
Date:
October 23, 2022 05:46
Subject:
Re: folder size
Message ID:
30315BC2-842F-4273-89ED-968E6824B0F3@acm.org


> On Oct 22, 2022, at 11:30 PM, ToddAndMargo via perl6-users <perl6-users@perl.org> wrote:
> 
> Hi All,
> 
> Does Raku have a folder size command (including sub
> folders)

> or is that a system call?

There are system calls to get sizes of individual files (Raku IO objects provide the same function via the `.s()` method), but even in C language, you have to walk the directory tree and ask for the sizes of each file, then sum them yourself.

The File::Find module can handle the walking for you, allowing for this tight solution:

raku -e "use File::Find; say find(dir => <.>)ยป.s.sum;"

-- 
Hope this helps,
Bruce Gray (Util of PerlMonks)
Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About