“找不到路径的一部分”是什么意思?

时间:2019-10-23 20:38:53

标签: powershell

get-childitemselect-string可以处理的路径大小是否受到限制?如果可以,那有什么选择?

当我在路径上运行以下命令时:

PS E:\KINGSTON backup5\03 Learning\Softwares\Mathematica\Mathematica 12\Mathematica Directories Backup2\C,Users,atfai,AppData,Roaming,Mathematica\Paclets\Repository\SystemDocsUpdate1-12.0.0\Documentation\English\Workflows> get-childitem -recurse -filter "*.nb" -file | select-string -pattern ".*ProcessObject.*" -casesensitive

我收到以下错误

  

选择字符串:文件E:\ KINGSTON backup5 \ 03   学习\软件\ Mathematica \ Mathematica 12 \ Mathematica目录   Backup2 \ C,用户,atfai,AppData,漫游,Mathematica \ Paclets \ Repository \ SystemDocsUpdate1-12.0.0 \ Documentation \ English \ Workflows \ ChangeTheStyleOfPointsInA2DScatterPlot.nb   无法读取:找不到路径'E:\ KINGSTON   backup5 \ 03学习\软件\ Mathematica \ Mathematica 12 \ Mathematica   目录   Backup2 \ C,用户,atfai,AppData,漫游,Mathematica \ Paclets \ Repository \ SystemDocsUpdate1-12.0.0 \ Documentation \ English \ Workflows \ ChangeTheStyleOfPointsInA2DScatterPlot.nb'。   在线:1字符:47   + ... nb“ -file |选择字符串-pattern”。 ProcessObject。“-区分大小写...   + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~       + CategoryInfo:InvalidArgument:(:) [Select-String],ArgumentException       + FullyQualifiedErrorId:ProcessingFile,Microsoft.PowerShell.Commands.SelectStringCommand

此外,如果我在以下路径上运行相同的命令:

PS E:\Computer Backup\Downloads - Current\Windows 10 Optimization\SoftwareDistribution.old3\Download\736aed4d238d4999f5ea5b04589077ed\Package_for_RollupFix~~amd64~~17134.677.1.6\x86_wcf-system.servicemodel_b03f5f7f11d50a3a_10.0.17134.254_none_d5ff175e12d127c0> get-childitem -recurse -filter "*.nb" -file | select-string -pattern ".*ProcessObject.*" -casesensitive

这次我从get-childitem收到错误

  

get-childitem:找不到路径'E:\ Computer的一部分   备份\下载-当前\ Windows 10   Optimization \ SoftwareDistribution.old3 \ Download \ 736aed4d238d4999f5ea5b   04589077ed \ Package_for_RollupFix ~~ amd64 ~~ 17134.677.1.6 \ x86_wcf-system.servicemodel_b03f5f7f11d50a3a_10.0.17134.254_none_d5ff175e12d127c0'。   在第1行:char:1   + get-childitem -recurse -filter“ * .nb”-文件|选择字符串模式...   + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~       + CategoryInfo:ReadError:(E:\ Computer Bac ... 5ff175e12d127c0:String)[Get-ChildItem],   DirectoryNotFoundException       + FullyQualifiedErrorId:DirIOError,Microsoft.PowerShell.Commands.GetChildItemCommand

“找不到路径的一部分”是什么意思?驱动器E具有Windows支持的NTFS文件系统,因此它的powershell命令应该能够处理它吗?这是怎么回事?

顺便说一句,我可以从Windows资源管理器访问这两个路径,并在记事本中打开文件。因此,路径存在并且文件显然没有损坏或无法访问。

2 个答案:

答案 0 :(得分:0)

问题是,您的操作系统未启用长路径,因此限制为260个字符。

根据运行的Windows版本,可以通过启用组策略Local Computer Policy > Computer Configuration > Administrative Templates > System > Filesystem > NTFS > Enable NTFS long paths来解决此问题。

如果您没有该选项,则将LongPathsEnabled处的注册表项HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\FileSystem的值从0更改为1即可。

答案 1 :(得分:0)

如果您无法使用其他答案的注册表或组策略修复,您可以使用前缀 df = pd.DataFrame({ 'event':['Sunday2021eat','MondayDonteat','FridayDont2023'],'day':[2021,2022,2023]})

<块引用>

要指定扩展长度的路径,请使用“\?”字首。例如,“\?\D:\非常长的路径”。 [...] 这 ”\?”前缀也可以与根据构造的路径一起使用 通用命名约定 (UNC)。要使用指定这样的路径 UNC,请使用“\?\UNC”前缀。例如,“\?\UNC\server\share”, 其中“服务器”是计算机的名称,“共享”是计算机的名称 共享文件夹。

参考:https://docs.microsoft.com/en-ca/windows/win32/fileio/maximum-file-path-limitation?tabs=cmd