【问题标题】:Cannot create Output directory error: 7zip无法创建输出目录错误:7zip
【发布时间】:2017-03-27 06:53:37
【问题描述】:

我正在使用 7zip 使用 powershell 提取我的 zip 文件,代码如下:

set-alias sz "$env:ProgramFiles\7-Zip\7z.exe"  
sz x -o:$destinationUnzipPath $zipfilePath -r ;

我收到以下错误:

错误:无法创建输出目录::D:\Temp\4.7-4.8\ System 错误:文件名、目录名或卷标语法是 不正确。

即使我手动创建目录,我仍然会遇到同样的错误。

如果我没有提供任何输出目录,下面是输出

7-Zip [64] 16.04:版权所有 (c) 1999-2016 Igor Pavlov:2016-10-04

扫描驱动器以查找存档:1 个文件,140483197 字节 (134 MiB)

解压存档:D:\Temp\4.7-4.8.zip -- 路径 = D:\Temp\4.7-4.8.zip 类型 = zip 物理大小 = 140483197

一切正常

文件夹:71 文件:3448 大小:1709276577 压缩:140483197

但我在 zip 目录或其他任何地方都找不到解压缩的文件。

【问题讨论】:

  • 去掉cmd中的冒号

标签: powershell 7zip


【解决方案1】:

这不是 powershell 问题,而是传递给 7-zip 的命令行参数中的问题。您已在不需要的-o 参数中添加了一个冒号。

改变这个

sz x -o:$destinationUnzipPath $zipfilePath -r ;

这应该可以工作

sz x -o$destinationUnzipPath $zipfilePath -r ;

【讨论】:

  • 如果文件已经存在,跳过解压的参数是什么?
  • 您可以使用Test-Path $destinationUnzipPath 来验证文件夹是否已经存在并跳过解压缩命令。
猜你喜欢
  • 2015-04-01
  • 1970-01-01
  • 2016-12-18
  • 1970-01-01
  • 2016-11-25
  • 1970-01-01
  • 1970-01-01
  • 2017-06-05
  • 1970-01-01
相关资源
最近更新 更多