PowerShell: filter files by wildcard
Filter file name by wildcard (-filter)
# list jpg files dir -recurse -file -filter *.jpg
# list emacs backup files. file name ending in TILDE dir -recurse -file -filter *~
about -filter and limitations
-filter is fast.
-filter
accept only Wildcards pattern with * and or ?.
No char class, and no multiple patterns, such as *jpg,*jpeg
Filter file name by multiple file extensions
You can use
-include or -exclude
with Wildcards
to filter out files by multiple file name extensions.
e.g.
-include *.jpg,*.jpeg
-include option is
applied after -filter result.
It is processed by PowerShell, is some 10 times slower than -filter.
-include
can have multiple wildcard patterns e.g. -include *.jpg,*.png
the Exclude parameter is applied after the Include parameter.
🛑 WARNING: when you use -include or -exclude, you must list by dir content, e.g. dir * or with -recurse
-include
dir * -file -include *.jpg,*.jpeg # or more complete syntax dir * -file -include "*.jpg","*.jpeg"
-exclude
dir * -file -exclude *.jpg,*.jpeg
PowerShell. list files
List Files
- PowerShell: list files
- PowerShell: show fullpath, no truncate lines
- PowerShell: list empty files 📜
- PowerShell: count files
filter
- PowerShell: filter files by wildcard
- PowerShell: filter file name by regular expression
- PowerShell: filter files by date
- PowerShell: list large files 📜
- PowerShell: search text in files (grep. find string)