I am trying to extract the data within a specific range of time from an input log file.
The input file, has the following pattern:
2023-01-31 00:00:21.354 FINE AS2SenderModule: Message sent and response received in 438 millisecondsms
2023-01-31 01:00:21.352 FINE AS2SenderModule: Message sent and response received in 479 millisecondsms
2023-01-31 09:00:23.368 FINE AS2SenderModule: Message sent and response received in 443 millisecondsms
2023-01-31 13:00:24.857 FINE AS2SenderModule: Message sent and response received in 393 millisecondsms
2023-01-31 14:00:26.758 FINE AS2SenderModule: Message sent and response received in 734 millisecondsms
I have tried the following ways but all have certain issues.
set /p start_time=Enter start time (HH:MM:SS):
set /p end_time=Enter end time (HH:MM:SS):
findstr /r "%start_time%.*%end_time%" input.txt > output.txt
This didn't work, it returned an empty output file.
The other workaround, which actually works, is no good to me. It is not dynamic, requiring user input, and only works for the same range pattern. What if the user input is like 08:00:00
to 13:00:00
?
for /f "tokens=11 delims= " %%a in ('findstr " 1[3-4]:[0-5][0-9]:[0-5][0-9] " input.txt ^| findstr /r /c:"millisecondsms"') do @echo %%a>> output.txt
Range can be any between 00:00:00
to 23:59:59
.
Please suggest a way.