如何使用与zip同名的winrar提取文件夹中的所有zip文件? [英] How to extract all zip files in a folder using winrar with the same name as the zip?

查看:153
本文介绍了如何使用与zip同名的winrar提取文件夹中的所有zip文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要遍历一个文件夹,对于每个zip文件,我都需要使用其名称解压缩它.也就是说,如果其为test.zip,则应将其解压缩到test文件夹.同样,它应该遍历我的文件夹及其子文件夹并提取内容.我写了下面的代码,但是没有提取出zip的名称.请指教.

I need to iterate a folder and for each zip file I need to extract it with the name of it. That is, if its test.zip then it should extract to test folder. Similarly it should iterate through my folder and its child folders and extract the things. I wrote the below code but it doesn't extract with the name of the zip. Please advice.

cd %CD%\Setups
for /r %%i in ("*.zip") do (
   echo "%%~fi"
    "C:\Program Files (x86)\WinRAR\WinRAR.exe" a -afzip "%%~dpi" "%%~fi"
    echo came after unzipping
    del /S /Q "%%~fi"
)
exit \b

推荐答案

使用Winrar.exe提取zip文件的语法如下:

The syntax for extracting zip files with Winrar.exe is like that :

[path \ winrar.exe] x [zip文件的路径] [要提取的文件,.对所有人 文件] [提取到的路径文件夹]

[path\winrar.exe] x [path to zip file] [files to extract, . for all files] [path folder to extract to]

@echo off
set winrar=%ProgramFiles%\WinRAR\WinRAR.exe
CD /D %CD%\Setups
for /f "delims=" %%i in ('Dir /b *.zip') Do ("%Winrar%" x "%%~fi" "%%~dpni\")
pause

在28/06/2016 @ 13:35修改

如果希望此开关-ibck在后台运行WinRAR,也可以添加:

You can also add if you want this switch -ibck to run WinRAR in background :

@echo off
set winrar=%ProgramFiles%\WinRAR\WinRAR.exe
CD /D %CD%\Setups
for /r %%i in ("*.zip") Do ("%Winrar%" x -ibck "%%~fi" "%%~dpni\")
pause

这篇关于如何使用与zip同名的winrar提取文件夹中的所有zip文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆