troubleshooting Question

DOS Batch files : looping

Avatar of MADHU_N
MADHU_N asked on
Windows BatchMicrosoft DOS
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

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

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

set classpath=%classpath%;%mydir2%\%1
goto :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.  



Thanks in advance and thank for previous answers .
Steve Knight
IT Consultancy

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 1 Comment.
Start Free Trial
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