I have list of text files in a folder, I want to:
Find the latest file in the folder
In the latest file, find the string = "Error"
Copy the whole row with string = "Error"
If there are more than 1 Error found, copy as it as well
Script below very simple, I am very new to batch script, can help me to correct to make it work?
set today=%date:~10,4%%date:~4,2%%date:~7,2%
set today_day=%date:~7,2%
set today_year=%date:~10,4%
set today_month=%date:~4,2%
set log_path=C:pathLog
set string=Error
FOR /F "delims=" %%I IN ('DIR %log_path%*.* /A:-D /O:-D /B') do set LATEST=%%I
If findstr /I /R /C:"%string%" %%I Do
Echo Copy the Error Message row
Else exit
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…