Cannot create Output directory error: 7zip

Cannot create Output directory error: 7zip

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

set-alias sz "$env:ProgramFiles-Zipz.exe"  
sz x -o:$destinationUnzipPath $zipfilePath -r ;

我收到以下错误:

ERROR: Can not create output directory: :D:\Temp.7-4.8\ System ERROR: The filename, directory name, or volume label syntax is incorrect.

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

如果我不提供任何输出目录,以下是输出

7-Zip [64] 16.04 : Copyright (c) 1999-2016 Igor Pavlov : 2016-10-04

Scanning the drive for archives: 1 file, 140483197 bytes (134 MiB)

Extracting archive: D:\Temp.7-4.8.zip -- Path = D:\Temp.7-4.8.zip Type = zip Physical Size = 140483197

Everything is Ok

Folders: 71 Files: 3448 Size: 1709276577 Compressed: 140483197

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

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

改变这个

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

这应该有效

sz x -o$destinationUnzipPath $zipfilePath -r ;