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 .
Windows BatchMicrosoft DOS

Avatar of undefined
Last Comment
Steve Knight
ASKER CERTIFIED SOLUTION
Avatar of Steve Knight
Steve Knight
Flag of United Kingdom of Great Britain and Northern Ireland image

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
Microsoft DOS
Microsoft DOS

Microsoft Disk Operating System (MS-DOS) was an operating system for x86-based personal computers, and traces of it are still found in the Windows operating system. DOS is still used in some embedded systems and for certain legacy 16-bit networks.

14K
Questions
--
Followers
--
Top Experts
Get a personalized solution from industry experts
Ask the experts
Read over 600 more reviews

TRUSTED BY

IBM logoIntel logoMicrosoft logoUbisoft logoSAP logo
Qualcomm logoCitrix Systems logoWorkday logoErnst & Young logo
High performer badgeUsers love us badge
LinkedIn logoFacebook logoX logoInstagram logoTikTok logoYouTube logo