Link to home
Start Free TrialLog in
Avatar of MADHU_N
MADHU_N

asked on

DOS Batch files : looping

Hi All

The following code I got from Genius when I asked question its working fine get ,stores list of files from folders in a variable but now there is another requirement.  I am not familiar with Batch files.


set myDir1=C:\test1
set myDir2=c:\test2
set classpath=


for /f "delims=" %%a in ('dir %myDir1% /b /a-d') do call :process1 %%a
goto :next

:process1
pause
if "%classpath%"=="" set classpath=%mydir1%\%1& goto :end
set classpath=%classpath%;%mydir1%\%1
goto :end

:next
for /f "delims=" %%a in ('dir %myDir2% /b /a-d') do call :process2 %%a
goto :end

:process2
set classpath=%classpath%;%mydir2%\%1
goto :end
:end

for loop is executing below the statements every time, what I need is it should not execute statements
-----------------------------------------------------------------------------------------------------------------------------
every time. I   need loop should store list of files from folders in a variable, once list of files stored in
----------------------------------------------------------------------------------------------------------------------------
variable then it   should execute following statements.  
-----------------------------------------------------------------


SET COMMAND=java -D%PROPERTIESS% -cp %CLASSPATH% %CLASS% %ARGUMENTS%

%COMMAND%

Thanks in advance and thank for previous answers .
ASKER CERTIFIED SOLUTION
Avatar of Steve Knight
Steve Knight
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial