如何使用批处理文件解压缩ZIP存档文件? [英] How to unzip a ZIP archive file using batch file?
问题描述
如果可能的话,我想使用.bat文件解压缩ZIP压缩的存档文件.没什么好说的,我只想将整个存档文件提取到相同的位置,即将.zip文件下载到桌面,并想将其提取到具有相同名称的桌面旁边.
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
推荐答案
您不需要循环.根据您是要提取存档中包含的目录结构还是要将所有内容都提取到单个目录,可以使用:
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
或
7z x C:\Users\Desktop\test.zip -o C:\Users\Desktop\test
请参见 https://sevenzip.osdn.jp/chm/cmdline/命令/index.htm 获取命令列表,并根据需要对各种选项进行深入分析.
See https://sevenzip.osdn.jp/chm/cmdline/commands/index.htm for a list of commands and drill down as needed for the various options.
批处理文件中不需要for循环,除非您打算仅基于模式列表提取文件.
You should not need a for loop in your batch file, unless you intend to only extract files based on a list of patterns.
这篇关于如何使用批处理文件解压缩ZIP存档文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!