dir E:\Music -File -Exclude *.mp3 -Recurse | foreach {del $_.FullName}
不工作?我測試了我所能想到的所有可能性,但仍然無法正常工作。
在此先感謝。
dir E:\Music -File -Exclude *.mp3 -Recurse | foreach {del $_.FullName}
不工作?我測試了我所能想到的所有可能性,但仍然無法正常工作。
在此先感謝。
我有同樣的問題,我使用了以下解決它:
dir E:\Music -File -Exclude *.mp3 -Recurse | Remove-Item
該命令看起來不錯,應該工作。如果將管道移除到foreach對象,你會得到任何輸出嗎?你在使用PowerShell v3嗎?試試看,你會得到WhatIf消息嗎?
dir E:\Music -File -Exclude *.mp3 -Recurse | del -WhatIf
參見實施例4從下面的命令
get-help remove-item -Examples
「因爲在此cmdlet Recurse參數是錯誤的...「
將是我的猜測。
這裏最酷的是你不需要'foreach',因爲'Remove-Item'會帶有流式輸入對象。 – 2013-04-02 05:20:20