Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/batch-file/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
If statement 将.txt的所有行替换为格式为xx:xx:xx的前8个字符,其中x是批处理文件中的整数_If Statement_Batch File_For Loop_Replace - Fatal编程技术网

If statement 将.txt的所有行替换为格式为xx:xx:xx的前8个字符,其中x是批处理文件中的整数

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

我将根目录中的每个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 (
    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个字符比较难,可能需要批处理文件中的大量代码。