本帖最后由 lky216 于 2012-7-3 13:27 编辑
每天最新的不是当天的日期创建的文件吗?那这样就好办,用date命令。
还是今天的备份昨天的?那试试这个- @echo off
- set DaysAgo=1
- >"%temp%\MyDate.vbs" echo LastDate=date()-%DaysAgo%
- >>"%temp%\MyDate.vbs" echo FmtDate=right(year(LastDate),4) ^& right("0" ^& month(LastDate),2) ^& right("0" ^& day(LastDate),2)
- >>"%temp%\MyDate.vbs" echo wscript.echo FmtDate
- for /f %%a in ('cscript /nologo "%temp%\MyDate.vbs"') do (
- set DstDate=%%a
- )
- set DstDate=%DstDate:~0,4%-%DstDate:~4,2%-%DstDate:~6,2%
- echo %DaysAgo%天之前(即昨天)的日期是:%DstDate%
- if exist "H:\backup\DB%DstDate:~0,4%%DstDate:~5,2%%DstDate:~8,2%.001" goto 1 ELSE goto 2
- :1
- echo 没有存在H:\backup\DB%DstDate:~0,4%%DstDate:~5,2%%DstDate:~8,2%.001这个文件
- pause&exit
- :2
- echo H:\backup\DB%DstDate:~0,4%%DstDate:~5,2%%DstDate:~8,2%.001>>D:\backup.txt
- pause
复制代码
|