2015-04-28 37 views
3

下面的代碼使用powershell/7za.exe來提取多個zip文件?

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

有以下錯誤消息。是powershell調用exe文件約定問題?

 
Error: 
Incorrect command line 

Error: 
Incorrect command line 

Error: 
Incorrect command line 
.... 

回答

1

我發現下面的腳本工程。

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

它需要在-o前添加一個反引號。雖然不知道原因。也許-o將被解釋爲powershell的選項,而不是可執行文件的?

3

這與7-ZIP命令行7za.exe工具有關。要使用相對路徑爲輸出目錄,它包裝成雙引號

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

注意路徑將是相對於當前目錄,而不是存檔或7za.exe