What is the FileSystem provider filter syntax? What is the FileSystem provider filter syntax? powershell powershell

What is the FileSystem provider filter syntax?


The filter syntax supported by the FileSystem provider is sparsely (if it all) documented, probably because there's nothing much to say.

In short, it only supports simple wildcard matching as you know it from Windows XP-era Search:

Any file with an extension:

*.*

Any file with the .txt extension:

*.txt

Partial wildcard matching:

*something*.txt

Single-character matching (matches myfile1.jpg but not myfile01.jpg):

myfile?.*

Simple character sets (this matches bear and beer):

be[ae]r

Simple character ranges (this matches filea.txt, fileb.txt and filec.txt):

file[a-c].txt

Note: It only supports a single expression per filter, so this is illegal:

*.jpg|*.txt