I am fairly new to windows batch files and have a problem with the following script :
rem @ echo off cls
set vendor=SHAMFOOD set dr=Y:\BPEL\Enterprise\kevin\ set filnm=Wahoo*.txt set mdl=_INV_ set ext=.txt set FOUND1=F
FOR /R %dr% %%G IN (%filnm%) DO ( rem echo %%G set FOUND1=F FOR /F "tokens=3 delims=~" %%H IN (%%G) DO ( IF "%FOUND1%"=="F" ( set filenam=%vendor%%mdl%%%H%ext% set FOUND1=T ) ) copy %%G test\%filenam% )
rem echo ren confirm_%NBR%.txt confirm_%item%.sr >>%1.txt rem echo %filenam%
I have a For Loop with in another for loop and I want to exit the inner one after 1 pass or at least not process any of the lines after the first one read. The code above is not working. The variable FOUND1 is not getting reset to "T". Can anyone tell me what is wrong with my code? Any HELP would be appreciated.
You need SETLOCAL ENABLEDELAYEDEXPANSION at the top of the file after @ECHO OFF Also, you need to changed %FOUND1% to !FOUND1! and then it should work.