troubleshooting Question

DOS Batch files : looping

Avatar of MADHU_N
MADHU_N asked on
Microsoft DOSWindows Batch
1 Comment1 Solution11433 ViewsLast Modified:
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 .
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 1 Comment.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 1 Comment.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros