Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Multiple conditions in For loop batch?

I'd like to print each line of 2 separate txt files alternately using a for loop in a batch file, I tried using an AND but was given: "AND was unexpected at this time" in cmd.exe when I ran my batch. Any ideas?

 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

 )
like image 883
jerryh91 Avatar asked May 07 '26 04:05

jerryh91


1 Answers

There isn't a keyword like AND, normally you couldn't solve this with two FOR loops.
But there is an alternative way to read a file with set /p.

setlocal EnableDelayedExpansion
<file2.txt (
  FOR /F "delims=" %%A in (file1.txt) DO (
    set /p lineFromFile2=
    echo file1=%%A, file2=!lineFromFile2!
  )
)
like image 66
jeb Avatar answered May 09 '26 03:05

jeb