-----getday.bat----获取日期
@echo off & setlocal
if [%1]==[] goto :Help
call :GetDayDiff %date:~0,10% %1 &goto :EOF
:GetDayDiff
call :Date2Day %1 days
set/a days=%days%+%2
call :Day2Date %days% result
echo %result% &goto :EOF
:Date2Day
setlocal ENABLEEXTENSIONS
for /f "tokens=1-3 delims=/-, " %%a in ('echo/%1') do (set yy=%%a & set mm=%%b & set dd=%%c )
set /a dd=100%dd%%%100,mm=100%mm%%%100
set /a z=14-mm,z/=12,y=yy+4800-z,m=mm+12*z-3,j=153*m+2
set /a j=j/5+dd+y*365+y/4-y/100+y/400-2472633
endlocal&set %2=%j%&goto :EOF
:Day2Date
setlocal ENABLEEXTENSIONS
set /a i=%1,a=i+2472632,b=4*a+3,b/=146097,c=-b*146097,c/=4,c+=a
set /a d=4*c+3,d/=1461,e=-1461*d,e/=4,e+=c,m=5*e+2,m/=153,dd=153*m+2,dd/=5
set /a dd=-dd+e+1,mm=-m/10,mm*=12,mm+=m+3,yy=b*100+d-4800+m/10
(if %mm% LSS 10 set mm=0%mm%)&(if %dd% LSS 10 set dd=0%dd%)
endlocal&set %2=%yy%-%mm%-%dd%&goto :EOF
:Help
echo xx 10 显示10天后的时间
echo xx -5 显示 5天前的时间
rem ------- EOF ---------
----backup.bat------备份文件
@echo off & setlocal
set dest_dir=%DATE:~0,10%
rem ---存在Z盘,先删除
net use Z: /delete
rem--- 映射229的E盘到本地Z盘
net use Z: /user:administrator
rem -- 调用getday.bat,取得7天前的日期并删除7天前的备份文件
call E:\scripts\getday.bat -7
del e:\backup\backup_%result%.rar /S /Q /F
rem -- 将C:\documents 打包备份,并copy至 229的E:\backup\目录下
rar a -r E:\backup\backup_%dest_dir%.rar C:\documents
xcopy E:\backup\backup_%dest_dir%.rar Z:\backup\ /S /Y
net use Z: /delete
阅读(1141) | 评论(0) | 转发(0) |