使用 powershell/7za.exe 提取多个 zip 文件?

Use powershell/7za.exe to extract multiple zip files?

下面的代码

ls *.zip | % { c:\binza.exe e $_ -o..\..\unzipped }
ls *.zip | % { c:\binza.exe e $_.name -o..\..\unzipped }

收到以下错误消息。是powershell调用exe文件的约定问题吗?

Error:
Incorrect command line

Error:
Incorrect command line

Error:
Incorrect command line
....

这与 7-ZIP 命令行 7za.exe 工具有关。要使用相对路径作为输出目录,请将其用双引号括起来,如

ls *.zip | % { c:\binza.exe e $_.FullName -o"..\..\unzipped" }

请注意,路径将是相对于当前目录的,而不是存档或 7za.exe

我发现以下脚本有效。

ls *.zip | % { c:\binza.exe e $_ `-o..\..\unzipped }

需要在-o前加一个反引号。虽然不知道是什么原因。也许 -o 将被解释为 powershell 的选项而不是可执行文件的选项?