I want to get the last two line and compare their time, and judge whether the time difference more than 20 seconds. Below is My batch file script and test file. I have successfully got the last two line and print out. When I split the time and compare it, I found the time will leading zero. How could I comare the two time? thanks in advance!
My test file:
08:00:05 I 0-ChecK Loop = 0 Start
08:00:05 I 8124-ChecK Loop = 8124 Start
08:00:15 I 8125-ChecK Loop = 8125 Start
08:00:25 I 8126-ChecK Loop = 8126 Start
08:00:35 I 8127-ChecK Loop = 8127 Start
08:00:42 I 8128-ChecK Loop = 8128 Start
My batch file:
@echo off
setlocal enabledelayedexpansion
for %%A in (C:\Users\Howard\Desktop\test.txt) do (
set "firstline="
set "secondline="
for /f "delims=" %%B in ('type "%%A"') do (
set firstline=!secondline!
set secondline=%%B
)
echo %%A !secondline!
)
for /f "tokens=1,2,3" %%i in ("!firstline!") do (
set time1=%%i
set I1=%%j
set count1=%%k
)
echo %time1%
::set /A T1="%time1:~1,2% * 24"
::set /a T1=(%time1:~0,2% * 24) + (%time1:~3,2% * 60) + (%time1:~6,2% *60)
::echo %T1%
echo %I1%
echo %count1%
for /f "tokens=1,2,3" %%i in ("!secondline!") do (
set time2=%%i
set I2=%%j
set count2=%%k
)
echo %time2%
echo %I2%
echo %count2%
pause
output: