bat调用winrar压缩文件

目的:实现一键复制文件,压缩文件
文件:rename.bat compression.bat
内容:
rename.bat:
@echo off
for /f "tokens=1-3 delims=/" %%i in ("%dete:~0,-3%") do set filename=%%i-%%j-%%k
set destnation=C:\Users\admin\Desktop\mail_report\
set location=C:\Users\admin\Desktop\
c:
cd %location%
echo .bat文件执行时间 %filename% > %destnation%warning.txt
if exist %location%增量1(2013-01-18).xls (copy %location%增量1(2013-01-18).xls %destnation%增量1(%filename%).xls) else echo 文件 %location%增量1(2013-01-18).xls 找不到>>%destnation%warning.txt
if exist %location%增量2(2013-01-18).xls (copy %location%增量2(2013-01-18).xls %destnation%增量2(%filename%).xls) else echo 文件 %location%增量2(2013-01-18).xls 找不到>>%destnation%warning.txt
if exist %location%增量3(2013-01-18).xls (copy %location%增量3(2013-01-18).xls %destnation%增量3(%filename%).xls) else echo 文件 %location%增量3(2013-01-18).xls 找不到>>%destnation%warning.txt
exit

compression.bat:
@echo off
set location=C:/Users/admin/Desktop/mail_report/
cd %location%
"C:/Program Files/WinRAR/WinRAR.exe" a -df -hp123abc -agYYYY-MM-DD -afrar -ep -m3 -o+ -t -ibck 房屋.rar *.xls
exit
说明:
双击rename.bat会将文件复制到另一个位置并在新文件名称中添加当时的系统日期,省去每次因时间变动而需要重命名的麻烦
双击compression.bat会直接将指定目录下的所有.xls文件以加密(包含文件名称)的方式在后台压缩成带有当前系统日期的rar文件,同时删除该目录下的源.xls文件

You may also like...

发表评论