Re: Your idea on how to detect random directory names

[email protected] (Paul Procacci)
Newsgroups perl.perl6.users
Message-ID <CAFbbPuhqJYzO1YLqey4jRUDPtF7vUzHGqYw1KSJ5++J3zr=7FQ@mail.gmail.com>
On Sat, Dec 9, 2023 at 2:06 AM Bruce Gray <[email protected]>
wrote:

>
>
> > On Dec 9, 2023, at 00:37, ToddAndMargo via perl6-users <
> [email protected]> wrote:
> >
> > Hi All,
> >
> > I am writing a clean up routine to relive my spot back ups
> > of junk in Blink browser directories that are meaningless to
> > a backup and that take up a lot of space.
> >
> > These directories are long and have random characters
> > for files names, such as "adcocjohghhfpidemphmcmlmhnfgikei"
> >
> > How who you go about figuring out who was random and
> > who was not.  I am thinking first the length and then
> > the absence of capitol letters and spaces and underscores.
> >
> > Your take?
>
>
> --snip--
>
> # Brave Browser temp directories: exactly 32 contiguous lowercase alpha
> characters.
> my $brave_junk_directories_re = / ^ <[a..z]> ** 32 $ /;
> my %to_skip = @filenames.grep($brave_junk_directories_re).Set;
>
>
I know this really wasn't mentioned clearly, but as a precaution you might
also want to consider filtering on whether the inode is referencing a file
or not:

my @to_skip = dir(".", test => { .IO.d && / ^ <[a..z]> ** 32 $ / } ) ;

If that possibility doesn't exist, then I personally would use:

my @to_skip = dir(".", test => { / ^ <[a..z]> ** 32 $ / } ) ;

As always, there's more than one way to skin a cat.

~Paul
-- 
__________________

:(){ :|:& };:
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.