Remove files when first two characters are ZZ Remove files when first two characters are ZZ powershell powershell

Remove files when first two characters are ZZ


Get all objects (including hidden, recursively) from a path with names starting with 'zz', filter out directory objects and delete the items.

Get-ChildItem <path> -Recurse -Force -Filter zz* | Where-Object {!$_.PSIsContainer} | Remove-Item


This works for me:

Remove-Item zz*


get-childitem zz* |  where-object {$_ -cmatch "^(zz|ZZ)"} |   foreach-item {remove-item $_.fullname}