PowerShell: Filter File Name by Regular Expression

By Xah Lee. Date: .

Filter File Name by Regular Expression

The where-object cmdlet is useful to filter files by a boolean test of Regular Expression pattern match.

# list jpg files
dir -recurse -file | where { $_.name -match "\.jpg|\.jpeg|\.jfif"}

PowerShell, List Dirs and Files

List Dirs

List Files

Create, Copy, Delete, Dir

Path Tutorial