Powershell 删除项不起作用

res*_*sgh 5 powershell

为什么是

dir E:\Music -File -Exclude *.mp3 -Recurse | foreach {del $_.FullName}
Run Code Online (Sandbox Code Playgroud)

不工作?我测试了我能想到的所有可能性,但仍然无法正常工作。

提前致谢。

小智 5

我遇到了同样的问题,我使用以下方法修复它:

dir E:\Music -File -Exclude *.mp3 -Recurse | Remove-Item
Run Code Online (Sandbox Code Playgroud)

  • 这里最酷的事情是您不需要“foreach”,因为“Remove-Item”将采用流式输入对象。 (2认同)