在其他帖子中看到了这个回帖,但是发现一个问题,就是系统时间小时位小于10的时候,算法有问题,不能准确判断,好像是05:05和5:05是两个数值。请大神帮忙修改一下,谢谢!
@echo off&setlocal enabledelayedexpansion
set "fn=e:\a.txt"
:loop
for %%a in ("%fn%") do (
if exist "%fn%" (
for /f "tokens=1-10 delims=/-: " %%i in ("%%~ta !date:~,10! !time:~,5!") do (
set/a y1=%%i,m1=1%%j%%100,d1=1%%k%%100,h1=1%%l%%100,f1=1%%m%%100,y2=%%n,m2=1%%o%%100,d2=1%%p%%100,h2=1%%q%
%100,f2=1%%r%%100
set /a "f=(1461*(y2+(m2-14)/12)/4+367*(m2-2-(m2-14)/12*12)/12-3*((y2+(m2-14)/12)/100+1)/4-1461*(y1+(m1-
14)/12)/4-367*(m1-2-(m1-14)/12*12)/12+3*((y1+(m1-14)/12)/100+1)/4-d1+d2)*1440+(h2-h1)*60+f2-f1"
if !f! LSS 15 (
start 1.txt
)
)
)
)
rem 延迟大约30秒后再次判断
ping /n 30 127.1 >nul
goto :loop@echo off
echo %date:~5,2%月%date:~8,2%日 %time:~0,2%:%time:~3,2%
pause