首页 > 解决方案 > 使用 powershell 解压缩嵌套的 zip 文件

问题描述

我有以下结构 Folder\zip\zip1, zip2, zip3

我想将 zip1、zip2、zip3 中包含的所有文件提取到一个文件夹中。

我尝试使用 Expand-Archive,但无法超出 zip 文件夹。

标签: powershellzipunzip

解决方案


如果结构如下所示:

/Folder/
  /Foo.zip
    /1.zip
    /2.zip

那么最简单的方法是:

Expand-Archive -LiteralPath 'c:\folder\Foo.zip' -DestinationPath 'C:\temp\Foo-expanded\'

# Get all the nested zip files, and expand them to the same folder:
Get-ChildItem 'C:\folder\expanded\*.zip' | 
  Expand-Archive -DestinationPath 'C:\folder\SingleFolder\'

Expand-Archive -Force如果要覆盖现有文件,请使用。


推荐阅读