我有一个文件夹中的文本文件列表,我想:寻找最新的文件,然后搜索字符串
找到该文件夹
在最新文件在最新文件中,找到字符串=“错误”
复制整行用绳子=“错误”
如果有超过1个发现错误,复制,因为它还有
脚本下面很简单,我对批处理脚本很陌生,可以帮助我正确地使它工作吗?
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:\path\Log\
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
不要[双后(https://stackoverflow.com/q/45436031)! – aschipfl
“复制整行”是什么意思?你想在哪里复制它?一份文件? – aschipfl