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

The following code

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

      

received the following error messages. Is this a powershell call causing the exe file issue?

Error:
Incorrect command line

Error:
Incorrect command line

Error:
Incorrect command line
....
+3


source to share


2 answers


I found the script to work.

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

      



He has to add a back side in front -o

. However, I don't know the reason. Maybe -o

interpreted as a powershell option instead of an executable?

+1


source


It has to do with the 7-ZIP command line 7za.exe

. To use a relative path as the output directory, enclose it in double quotes as

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

      



Note that the path will refer to the current directory, not the archive or 7za.exe

.

+3


source







All Articles