NNMHUB
🗜️

批量压缩/解压 ZIP

免费在线

把一批子文件夹批量打包成 zip,或批量解压目录下所有 zip,零安装。

Windows压缩ZIP

🗜️Windows 本地工具 · 使用介绍

使用介绍

用途:

  • 批量压缩:目录下每个子文件夹 → 同名 zip(如 `合同/` → `合同.zip`)
  • 批量解压:目录下所有 zip → 各自同名文件夹

使用步骤:

1.下载脚本,双击 `run.bat` 运行

2.选择 1 压缩 / 2 解压,输入目录路径

3.等待完成

说明:使用 Windows 自带压缩功能,无需安装任何软件;同名输出已存在时自动跳过,不覆盖。

下载脚本 (.ps1) 双击启动器 (.bat)建议两个都下载,放到同一文件夹

脚本为纯文本(PowerShell),可先用记事本打开查看源码再运行;仅在本机执行,不会上传任何数据。 首次运行如被系统拦截,右键脚本 → 属性 → 解除锁定,或用启动器(已带 ExecutionPolicy Bypass)运行。

脚本源码预览(可复制)

# ==================================================
# 批量压缩 / 解压 ZIP(NMHUB 牛马工具)
# 压缩:把选中的文件夹逐个打包为 zip
# 解压:把目录下所有 zip 解压到同名文件夹
# 安全:仅新增文件,不删除原文件
# ==================================================
$ErrorActionPreference = "Continue"

Write-Host ""
Write-Host "========== 批量 ZIP 压缩 / 解压 ==========" -ForegroundColor Cyan
Write-Host "1) 批量压缩(每个子文件夹 -> 同名 zip)"
Write-Host "2) 批量解压(所有 zip -> 同名文件夹)"
$mode = Read-Host "选择 1/2"

$dir = Read-Host "请输入目标目录(回车 = 当前目录)"
if (-not $dir) { $dir = (Get-Location).Path }
if (-not (Test-Path -LiteralPath $dir)) {
    Write-Host "路径不存在。" -ForegroundColor Red
    Read-Host "按回车退出"; exit 1
}

if ($mode -eq "1") {
    $items = Get-ChildItem -LiteralPath $dir | Where-Object { $_.PSIsContainer }
    if ($items.Count -eq 0) { Write-Host "没有子文件夹可压缩。" -ForegroundColor Yellow; Read-Host "按回车退出"; exit }
    $i = 0
    foreach ($it in $items) {
        $zip = Join-Path $dir "$($it.Name).zip"
        if (Test-Path -LiteralPath $zip) {
            Write-Host "跳过(已存在): $($it.Name).zip" -ForegroundColor Yellow
            continue
        }
        Compress-Archive -Path $it.FullName -DestinationPath $zip -CompressionLevel Optimal -ErrorAction SilentlyContinue
        if ($?) { Write-Host "已压缩: $($it.Name).zip"; $i++ } else { Write-Host "失败: $($it.Name)" -ForegroundColor Red }
    }
    Write-Host "完成,压缩 $i 个文件夹。" -ForegroundColor Green
}
elseif ($mode -eq "2") {
    $zips = Get-ChildItem -LiteralPath $dir -Filter *.zip -File
    if ($zips.Count -eq 0) { Write-Host "没有 zip 文件。" -ForegroundColor Yellow; Read-Host "按回车退出"; exit }
    $i = 0
    foreach ($z in $zips) {
        $target = Join-Path $dir $z.BaseName
        if (Test-Path -LiteralPath $target) {
            Write-Host "跳过(同名文件夹已存在): $($z.BaseName)" -ForegroundColor Yellow
            continue
        }
        Expand-Archive -LiteralPath $z.FullName -DestinationPath $target -ErrorAction SilentlyContinue
        if ($?) { Write-Host "已解压: $($z.Name)"; $i++ } else { Write-Host "失败: $($z.Name)" -ForegroundColor Red }
    }
    Write-Host "完成,解压 $i 个 zip。" -ForegroundColor Green
}
else {
    Write-Host "输入无效。" -ForegroundColor Red
}

Read-Host "按回车退出"