info2m
October 13, 2019, 9:54pm
1
Hi,
I’m having issue with the unzipping a file in a directory tree.
Example scenario:
C:\Source\project\bin\login.zip
but in my scenario, I want to unzip my files in Project sub-folder
Please let me know if it is possible in Powershell script, any line of code or a example will be helpful.
Thanks,
How are you trying to do it ? You can use Expand-Archive cmdlet (V 5 onwards) to unzip and use the -DestinationPath to your desired path.
stax76
October 14, 2019, 3:51am
3
You can also use the CLI version of 7zip.
Some code I use for unpacking:
foreach ($arg in $args) {
$file = Get-Item $arg
& "C:\Program Files\7-Zip\7z.exe" x "$arg" -o"$($file.DirectoryName)"
if ($LastExitCode -gt 0) {
Write-Host "`nError: Exit code $LastExitCode`n" -ForegroundColor Red
Pause
}
}
This is kind of invoking expression, but if you are looking for PowerShell to get this job done, then as @kvprasoon mentioned you need to use Expand-Archive cmdlet.
Thank you.