Delete multiple files on PowerShell command line
You can give PowerShell's rm
cmdlet (which is itself an alias for Remove-Item
) several files, but you need to separate them with commas.
rm .\subDir\a.png, .\anotherDir\b.jpg, .\thirdDir\c.gif
Check out Get-Help Remove-Item
for more details. Or read some documentation on Microsoft's website.
This is what I ended up using:
echo subDir/a.png anotherDir/b.jpg thirdDir/c.gif|rm
This uses echo to pass three string arguments to rm (Remove-Item). I believe this implicitly uses Remove-Item's -Path
parameter. The documentation notes that "The parameter name ("-Path") is optional" and it accepts pipeline input by value.