gpt4 book ai didi

batch-file - For循环批处理中的多个条件?

转载 作者:行者123 更新时间:2023-12-04 21:44:55 24 4
gpt4 key购买 nike

我想在批处理文件中使用 for 循环交替打印 2 个单独的 txt 文件的每一行,我尝试使用 AND 但在我运行时在 cmd.exe 中给出:“AND was unexpected at this time”我的批处理。有什么想法吗?

 FOR /F "tokens=*" %%F in (!logPath!) AND for /f "tokens=*" %%H in (%%refLogPath) DO ( 

REM print each line of log file and refLog file sequentially
echo %%F
echo %%H
REM set logLine=%%F
REM check 'each line' of log file against ENG-REF.log

)

最佳答案

没有像AND这样的关键字,通常你不能用两个FOR循环来解决这个问题。
但是还有另一种方法可以使用 set/p 读取文件。

setlocal EnableDelayedExpansion
<file2.txt (
FOR /F "delims=" %%A in (file1.txt) DO (
set /p lineFromFile2=
echo file1=%%A, file2=!lineFromFile2!
)
)

关于batch-file - For循环批处理中的多个条件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11230722/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com