Quantcast
Channel: Recursion – Geekality
Viewing all articles
Browse latest Browse all 4

PowerShell: Search for and delete files recursively

$
0
0

Short and simple, but keep forgetting some minor details, so… note to self

# Files
gci -recurse -force |
where {$_.name -eq "Thumbs.db"} |
foreach {ri $_.fullname -whatif}

# Directories (and using regex for matching)
gci -recurse -force |
where {$_.name -match "^(bin|obj)$"} |
foreach {ri $_.fullname -recurse -whatif}

Minus the -whatif, of course 🙂


Viewing all articles
Browse latest Browse all 4

Trending Articles