• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.

What expressions can you specify in the -filter param for dir

B

Bob Landau

#1
I'm trying to better understand what expressions can be used in the -filter
parameter for the get-childitem cmdlet.

I've looked in the following helpfiles

get-childitem
about_wildcards
about_providers
< and a few others>

The documentation for get-childitem states the syntax and use of wildcards
for the filter parameter is dependant on the provider.

The documentation for about_wildcards states that besides the well know * ?
wildcards you can use ranges and sets.

The documentation for about_provider did not address this.

Below is what I've found by experimentation


c:> cd \windows\system32
c:\windows\system32>: get-childitem -filter a?* # works as expected

c:\windows\system32>: get-childitem [a-b]?* # works as expected

c:\windows\system32>: get-childitem -filter [a-b]?* # doesn't work


Does the "provider" not provide this type of wildcard? Bug?


How are you suppose to know what you can use; trial and error?

I'm hoping that someone can point to some documentation that shows what
syntax each provider can use in the -filter parameter

thanks again

bob
 

My Computer

K

Kiron

#2
Get-ChildItem's -filter, -include, -exclude accept wildcards '*,?', no regex
patterns nor ranges. Ranges are passed to the -path parameter.

get-childitem -path [a-b]?* # should work

--
Kiron
 

My Computer

B

Bob Landau

#3
I appreciate the response however this is not what I've found to be the case.
From what the doc state

-include, -exclude

are both process by Powershell itself so are capable of handling regex.

-filter however is an escape mechanism which passes the processing to the
provider.

Try this

c:\windows\system32> get-childitem *.* -include [a-z]?*.dll -exclude
[abcdefghijklmn]?*.*


This works as expected. The problem evidently is no one other than a few
Microsoft developers and possibly testors know absolultely what is allowed
for the filter parameter.

Oh well, I'm sure the doc's well get better

bob

"Kiron" wrote:

> Get-ChildItem's -filter, -include, -exclude accept wildcards '*,?', no regex
> patterns nor ranges. Ranges are passed to the -path parameter.
>
> get-childitem -path [a-b]?* # should work
>
> --
> Kiron
>
 

My Computer

Users Who Are Viewing This Thread (Users: 1, Guests: 0)