Matt Gerrans
Posts: 1153
Nickname: matt
Registered: Feb, 2002
|
|
Re: "for loop : problem in batch file
|
Posted: Jul 29, 2005 4:27 PM
|
|
Hi Kondwani,
Yes, on Unix-based systems you use the colon, but Windows-based systems, you use semicolon. Based on what the OP had written, I thought it was Windows not Unix.
By the way, I found out the way do do it without a temporary file. It is pretty arcane, but here it is:setlocal EnableDelayedExpansion set JarsDir=D:\ant\apache-ant-1.6.1\lib if defined classpath (set classpath=%classpath%;.) else (set classpath=.) for %%i in ("%JarsDir%\*.jar") do set classpath=!classpath!;%%i endlocal & set classpath=%classpath% The trick is that if you chain the set command to the to the endlocal command, you are in some quasi-state where you can set variables in the outer environment from the inner one. Pretty strange, but it works.
|
|