You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

PowerShell如何将每个zip文件解压到与压缩包同名的无后缀子文件夹

批量解压zip到同名无后缀文件夹的PowerShell简洁写法

1行实现(默认覆盖已有目标文件)

Get-ChildItem *.zip | ForEach-Object { Expand-Archive $_.FullName -DestinationPath ($_.FullName -replace '\.zip$', '') -Force }

带目标文件夹存在判断的2行写法(仅文件夹不存在时解压)

Get-ChildItem *.zip | ForEach-Object { $dst = $_.FullName -replace '\.zip$', ''
if (!(Test-Path $dst)) { Expand-Archive $_.FullName -DestinationPath $dst } }

说明

  • 要遍历当前目录及所有子目录的zip文件,在Get-ChildItem后添加-Recurse参数即可
  • 要指定扫描的根目录,将Get-ChildItem *.zip修改为Get-ChildItem 你的目标路径\*.zip
  • 写法依赖PowerShell 5.1及以上版本内置的Expand-Archive命令,Windows 10/11及Server 2016以上系统默认自带无需额外安装

内容的提问来源于stack exchange,提问作者YorSubs

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.09.30 01:15:07