Windows batch Nested foor loop issue -
Windows batch Nested foor loop issue -
i need read file in outer loop line line... take value , utilize in inner loop. able read first line file , required processing in inner loop outer loop runs once... can please find here why outer loop runs once?
myfile.txt contains: awc00201 awc00202 awc00203 dddd
@echo off setlocal enabledelayedexpansion /f %%d in (myfile.txt) ( echo %d% s: cd \@vantage\afg\awc\awcu\simulation\wro_regression_results\%%d echo %%d /f %%i in ('dir /b /ad-h /o-d') ( echo after nested echo %%d set test=%%d set b=%%i goto found ) echo no subfolder found goto done :found echo %d% echo recent subfolder: %b% cd %b% echo %%d find /c "o k" tooling.report echo %d% if %errorlevel% equ 1 goto notfound echo found goto done :notfound echo notfound goto done :done echo %d% echo go echo !test! echo %test% ) pause
i getting next output:
echo off. awc00201 after nested awc00201 echo off. recent subfolder: 20141103_170658_wro_awc %d ____________ tooling.report: 0 echo off. notfound echo off. go awc00201 awc00201 press key go on . . .
i appreciate quick response.
thank you.
your code has 1 big problem , 1 thing change
the problem is not possible utilize goto
while within for
loop , maintain loop iterating. goto
cancels for
looping.
the thing alter utilize of variables. have info need within for
replaceable parameters. utilize them. move value variable when replaceable parameters not offer need, not case
@echo off setlocal enableextensions disabledelayedexpansion /f "delims=" %%d in (myfile.txt) ( cd /d "s:\@vantage\afg\awc\awcu\simulation\wro_regression_results\%%d" /d %%a in (.) echo current folder "%%~fa" set "file=" /f "delims=" %%i in ('dir /b /ad-h /o-d 2 >nul ') if not defined file ( set "file=1" echo subfolder found : %%i find /c "o k" ".\%%i\tooling.report" >nul 2>nul if errorlevel 1 ( echo o k found ) else ( echo o k not found or file not exist ) ) if not defined file ( echo subfolder not found ) ) pause
windows batch-file
Comments
Post a Comment