Get-ChildItem -Path C:\ -Filter CAPS*
finds caps.txt I want to make sure it will only find CAPS.txt (or e.g. CAPS901918.whatever)
I've tried find ways to pipe the Filter to an expression like:
{ $_.What_I_just_said_to_filter_on -like [A-Z] }
or suppress output after receiving results but I have found nothing.
try piping Get-Childitem to Where-Object like this:
Get-Childitem -Path C:\ | Where-Object {$_.what_you_want_to_filter -cmatch "REGEX"}
here it is with like syntax (thanks FLGMwt)
Get-Childitem -Path C:\ | Where-Object {$_.Name -clike "CAPS*"}
The FileSystem provider's filter is not case sensitive, but you can pipe it to:
Where{-NOT ($_.BaseName -cmatch "[a-z]")}
That will find files that do not contain lower case letters. If you match against upper case it will work for any file that has at least 1 capital letter, and can still include lower case.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With