【发布时间】:2015-04-03 07:23:15
【问题描述】:
这让我很沮丧,所以我向你们寻求帮助..
我有一百万个(有点夸张)文件夹要删除,我可以一个一个地从 Windows 资源管理器中删除 YAY...但我想在 Powershell(版本 4)中编写脚本
使用此代码:
$Path = '\\verylonguncpath\plussomemore\'
Remove-Item -Path $Path -Recurse -Force -Confirm:$False
我得到错误:
Remove-Item : The specified path, file name, or both are too long. The fully qualified file name must be less than 260 characters, and the directory name must be less than 248
characters.
At line:5 char:1
+ Remove-Item -Path $Path -Recurse -Force -Confirm:$False
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : WriteError: (\\verylongpath\plussomemore:String) [Remove-Item], PathTooLongException
+ FullyQualifiedErrorId : RemoveItemIOError,Microsoft.PowerShell.Commands.RemoveItemCommand
如果$Path 不是很长,它可以工作......
我什至尝试映射到一个字母然后删除内容,但我遇到了同样的问题?
显然它的 Microsoft 或 Powershell 是我一直在阅读的问题?
可能是用户错误:\
任何建议都会很棒,我真的很想只使用 MS 产品,但第三方程序会很好(在 Powershell 脚本中使用)..
谢谢帕夫。
【问题讨论】:
-
资源管理器正确处理这些非常长的路径?
-
我认为这或多或少是一个重复的问题。见这里:[stackoverflow.com/questions/16392765/…[1]:stackoverflow.com/questions/16392765/…
标签: powershell scripting powershell-ise powershell-4.0