How to unzip a ZIP archive file using batch file? [duplicate]

三世轮回 提交于 2020-03-03 05:46:11

问题


I would like to use a .bat file to unzip a ZIP compressed archive file if possible at all. Nothing fancy, I just want to extract the entire archive file to the same location, i.e. download a .zip file to desktop and want to extract it next to desktop with the same name.

I tried this, but with no success.

for /R "C:\Users\Desktop\test.zip" %%I in ("*.zip") do(
   "%ProgramFiles(x86)%\7-zip\7z.exe" x - y -o"%%~dpnI" "%%~fI"
)
exit

回答1:


You shouldn't need the loop. Depending on whether you want to extract the directory structure contained within the archive or just extract everything to a single directory, you would use:

7z e C:\Users\Desktop\test.zip -o C:\Users\Desktop\test

or

7z x C:\Users\Desktop\test.zip -o C:\Users\Desktop\test

See https://sevenzip.osdn.jp/chm/cmdline/commands/index.htm for a list of commands and drill down as needed for the various options.

You should not need a for loop in your batch file, unless you intend to only extract files based on a list of patterns.



来源:https://stackoverflow.com/questions/53245157/how-to-unzip-a-zip-archive-file-using-batch-file

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!