当前位置:   article > 正文

通过批处理文件bat 编辑dos命令 实现7z 批量压缩指定文件夹下内容_7z 多个文件夹压缩 批处理

7z 多个文件夹压缩 批处理

@echo off

echo -------------Start to zip files by 7z------------------

:start

::输入目标目录
echo please input the root directory which you want zip
set /p target_directory=

::判断非法输入
if "%target_directory%"=="" goto :start
if exist %target_directory% if not exist %target_directory%\nul echo INVALID INPUT: %target_directory% &goto:start


::记录执行文件路径
set current_directary=%cd%
::进入目标路径
cd %target_directory%
::如果是其他区
if "%cd%"=="%current_directary%" cd /d %target_directory%


::设置参数(记得修改为自己的参数)
set "exe_dir=D:\Program Files (x86)\7-Zip\7z.exe"
set "my_secret=123456"
set "info_log=%current_directary%\7z_INFO.log" 
set "error_log=%current_directary%\7z_ERROR.log" 

 

::以下注释可用于调试
::echo %target_directory%
::echo %current_directary%
::pause
::goto start
 

::进行压缩
for %%X in (*) do "%exe_dir%" a "%%X.7z" -p%my_secret% -mhe -mx=5  "%%X" 1>>%info_log% 2>>%error_log%
for /d %%X in (*) do "%exe_dir%" a "%%X.7z" -p%my_secret% -mhe -mx=5 "%%X" 1>>%info_log% 2>>%error_log%


::提示压缩完毕
mshta vbscript:createobject("sapi.spvoice").speak("zip files have finished")(window.close)
mshta vbscript:msgbox("zip files have finished",1,"My 7z")(window.close)


goto start

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/繁依Fanyi0/article/detail/320643
推荐阅读
相关标签
  

闽ICP备14008679号