PowerShell: Unzip Multiple Zip Files To A Directory

preview_player
Показать описание


Рекомендации по теме
Комментарии
Автор

Nice and elegant! Thank you.

Based on the name of your function, I assume this was a compress to zip file function previously?

Thanks again for your videos, always very helpful and to the point.

Zellpages
Автор

If you have the same name it wont copy both files. any solution for this?

Dude-WheresMyCar
Автор

I have multiple zips with the same file names inside them. So I need to extract them into directories with the zip file name. I tried this script today and it would not work. Instead of creating a directory with the zip name, it just extracted the 1st zip to the destination directory and then attempted to extract the 2nd zip but it gave an error since the file names already exist in the destination. So I had to tweak the code. Here is the code that I added that made it work:

Under the foreach section, I added a $newdest and then changed the ExtractToDirectory to go to $newdest

foreach ($zp IN $zps)

{

$all = $src + $zp

$newdest = $dest + $zp

[System.IO.Compression.ZipFile]::ExtractToDirectory($all, $newdest)

}

justKT