本文介绍了Windows批处理脚本来解压缩目录中的文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我要解压缩时解压缩在某个目录和preserve文件夹名称中的所有文件。
以下批处理脚本并不完全做的伎俩。它只是抛出一大堆的文件,而不将它们放入一个文件夹,甚至没有完成。
什么是错在这里?
FOR / F %% I IN('DIR / B / S * .zip文件')DO( C:\\ Program Files文件(x86)的\\ 7-Zip的\\ 7z.exeX -y -o%%〜DPI我%%
)
解决方案
试试这个:
为/ RC:\\ ROOT \\文件夹%%我在(* .zip文件),做(
为%ProgramFiles(x86)的%\\ 7-Zip的\\ 7z.exeX -y -o%%〜DPI%%〜FI
)
或者(如果您想将文件解压缩到一个Zip文件命名的文件夹):
为/ RC:\\ ROOT \\文件夹%%我在(* .zip文件),做(
为%ProgramFiles(x86)的%\\ 7-Zip的\\ 7z.exeX -y -o%%〜DPNI%%〜FI
)
I want to unzip all files in a certain directory and preserve the folder names when unzipped.
The following batch script doesn't quite do the trick. It just throws a bunch of the files without putting them into a folder and doesn't even finish.
What's wrong here?
for /F %%I IN ('dir /b /s *.zip') DO (
"C:\Program Files (x86)\7-Zip\7z.exe" x -y -o"%%~dpI" "%%I"
)
解决方案
Try this:
for /R "C:\root\folder" %%I in ("*.zip") do (
"%ProgramFiles(x86)%\7-Zip\7z.exe" x -y -o"%%~dpI" "%%~fI"
)
or (if you want to extract the files into a folder named after the Zip-file):
for /R "C:\root\folder" %%I in ("*.zip") do (
"%ProgramFiles(x86)%\7-Zip\7z.exe" x -y -o"%%~dpnI" "%%~fI"
)
这篇关于Windows批处理脚本来解压缩目录中的文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!