Front page | perl.perl6.users |
Postings from October 2022
Re: folder size
Thread Previous
|
Thread Next
From:
William Michels via perl6-users
Date:
October 24, 2022 19:27
Subject:
Re: folder size
Message ID:
CAA99HCy+1_-OHbuGp1GJ65wjjURONUcTggsEMjHt1DmsrEn_PA@mail.gmail.com
Hi Todd,
Thanks for the code! Unfortunately I see this error:
Variable '$PathIAm' is not declared. Perhaps you forgot a 'sub' if
this was intended to be part of a signature?
at -:3
------> [32m my Str $BatFile = [33m⏏ [31m$PathIAm ~ ".bat"; [0m
On Sun, Oct 23, 2022 at 9:56 PM ToddAndMargo via perl6-users <
perl6-users@perl.org> wrote:
> On 10/22/22 21:30, ToddAndMargo via perl6-users wrote:
> > Hi All,
> >
> > Does Raku have a folder size command (including sub
> > folders) or is that a system call?
> >
> > Many thanks,
> > -T
>
> My final code:
>
>
> sub RunCmd( Str $CommandStr, Bool $EchoOff = False ) {
> my Str $BatFile = $PathIAm ~ ".bat";
> my Str $RtnStr;
> my Str $CmdStr = "";
>
> if $EchoOff { $CmdStr = Q[@echo off] ~ "\n"; }
> $CmdStr = $CmdStr ~ $CommandStr ~ "\n";
> # print "$CmdStr";
>
> spurt( $BatFile, $CmdStr );
> $RtnStr = qqx { $BatFile };
> # print "$RtnStr\n";
> return $RtnStr;
> }
>
>
> sub DirectoryExists( Str $DirPath --> Bool ) { return
> "$DirPath".IO.d.Bool; }
>
> sub FolderSize( Str $FolderPath --> Int ) {
> # dir . /s /A:-D /d /a | raku -e "say lines[*-2].words[2]"
> # 3,275,848,795
> # > my Str $x="123,456,789"; $x~~s:g/","//; say $x; $y=$x.Int; say $y
> # 123456789
> # 123456789
>
> my $SubName = &?ROUTINE.name;
> my Str $RtnStr = "";
> my Str $ErrMsg = "";
> my Int $Size = 0;
>
> if not DirectoryExists( $FolderPath ) {
> $ErrMsg = "$IAm\:$SubName error: FolderPath <$FolderPath> doesn
> not exist\n\n";
> MessageBox $IAm, $ErrMsg, MB_ICONERROR, MB_OK;
> print $ErrMsg;
> return 0;
> }
>
>
>
Thread Previous
|
Thread Next