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

Re: folder size

Thread Previous | Thread Next
Bruce Gray
October 23, 2022 05:46
Re: folder size
Message ID:

> On Oct 22, 2022, at 11:30 PM, ToddAndMargo via perl6-users <> 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 Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About