If statement 将.txt的所有行替换为格式为xx:xx:xx的前8个字符,其中x是批处理文件中的整数
我将根目录中的每个properties.log文件:c:\executionsdktest_10.2.2与参考文件进行比较。xx:xx:xx格式的执行时间打印在ref和properties.log文件28行的前8个字符中,因为时间不同且无关紧要,我想跳过包含时间的任何行的前8个字符。我怎样才能做到这一点If statement 将.txt的所有行替换为格式为xx:xx:xx的前8个字符,其中x是批处理文件中的整数,if-statement,batch-file,for-loop,replace,If Statement,Batch File,For Loop,Replace,我将根目录中的每个properties.log文件:c:\executionsdktest_10.2.2与参考文件进行比较。xx:xx:xx格式的执行时间打印在ref和properties.log文件28行的前8个字符中,因为时间不同且无关紧要,我想跳过包含时间的任何行的前8个字符。我怎样才能做到这一点 REM assume <refLog>.txt exists <!logPath! ( For /F "tokens=*" %%R in (!refLogPath!) DO
REM assume <refLog>.txt exists
<!logPath! (
For /F "tokens=*" %%R in (!refLogPath!) DO (
set logLine=
set /p logLine=
set refLogLine=%%R
REM Check line by line of log against refLog
REM if corresponding lines mismatch: skip xx:xx:xx
if NOT "!logLine!"=="!refLogLine!" (
Echo.
Echo line below is Incorrect:
set lnCorrect=false
REM output to command line: can be put into .log/.txt later
REM output ANY and ALL incorrect line in log file
ECHO !logLine!
)
)
)
REM-aspect.txt存在
您可以使用
!logLine:~8!
这将从行中删除前8个字符。当然,对于refLogLine
,同样如此。Hey@Joey我需要一个更通用的方法,无论我在哪里看到xx:xx:xx,我都想跳过这8个字符。这8个字符比较难,可能需要批处理文件中的大量代码。