Re: Your idea on how to detect random directory names

[email protected] (ToddAndMargo via perl6-users)
Newsgroups perl.perl6.users
Message-ID <[email protected]>
What I have so far:


#!/usr/bin/env perl6

#`{
Clean up the useless to a back up directories in Brave Browser

$ ls ~/.config/BraveSoftware/Brave-Browser
  adcocjohghhfpidemphmcmlmhnfgikei   GrShaderCache
...
}

use lib '/home/linuxutil/p6lib';
use RunNoShellLib :RunNoShell;
use PrintColors :PrintRed, :PrintGreen, :PrintBlue, :PrintErr, 
:PrintRedErr, :PrintGreenErr, :PrintBlueErr;


( my $ProgramName   = $?FILE ) ~~ s|.*"/"||;
my Str $BaveDir     = %*ENV<HOME> ~ "/.config/BraveSoftware/Brave-Browser";
my Str $DirsToWhack = "";

for dir $BaveDir -> $Line  {
    # print $Line ~ "\n";
    if  $Line.chars != 79 || $Line.contains( "_" || "-" || " " )  {
       # print "Skip; chars = <" ~ $Line.chars ~ ">  Line = <$Line>\n";
       next;
    }

    # print $Line ~ "\n";
    ( my $DirName  = $Line ) ~~ s/ .* $( Q[/] ) //;
    if  $DirName.lc eq $DirName {
         $DirsToWhack ~= $Line ~ "\n";
         # print $DirName ~ "\n";
    }
}
# print "Whack directories\n$DirsToWhack\n";

if $DirsToWhack.chars > 0  {
    for $DirsToWhack.lines -> $Line  {
       # PrintBlue "removing <$Line>\n";
       PrintBlue "rm -rf $Line\n";
       RunNoShell "rm -rf $Line";
    }

} else {
    PrintGreen "No directories found to clean out (Whack)\n";
}

# With that, I shall "Whack" no more
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.