[英]Use powershell/7za.exe to extract multiple zip files?
以下代碼
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 ....
這與7-ZIP命令行7za.exe
工具有關。 要將相對路徑用作輸出目錄,請將其包裝為雙引號
ls *.zip | % { c:\bin\7za.exe e $_.FullName -o"..\..\unzipped" }
請注意,路徑將相對於當前目錄,而不是存檔或7za.exe
。
我發現以下腳本有效。
ls *.zip | % { c:\bin\7za.exe e $_ `-o..\..\unzipped }
它需要在-o
前面添加一個反引號。 不知道原因。 也許-o
將被解釋為powershell的選項而不是可執行文件?
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.