Multiple conditions in For loop batch

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
jerryh91
Posts: 2
Joined: 27 Jun 2012 10:52

Multiple conditions in For loop batch

#1 Post by jerryh91 » 27 Jun 2012 10:54

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?

Code: Select all

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

 )

foxidrive
Expert
Posts: 6031
Joined: 10 Feb 2012 02:20

Re: Multiple conditions in For loop batch

#2 Post by foxidrive » 27 Jun 2012 11:03

From a previous thread:

Code: Select all

@echo off
setlocal DisableDelayedExpansion
< file2.txt (
   for /F "delims=" %%a in (file1.txt) do (
      set file2Line=
      set /P file2Line=
      set "file1Line=%%a"
      setlocal EnableDelayedExpansion   
      echo(!file1Line! !file2Line!
      endlocal
   )
)
pause

Post Reply