Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
Hi,
I'm trying to make a file or variable that contains a semicolon separated list of files in a dir.
for %%i in (*.jar) do call echo %%i; >> jarlist.txt
or
for %%i in (*.jar) do set CPATH=%CPATH%;%%i
Does not work because echo will add a CR/LF pair and for some strange reason only the last file in the list will be added to CPATH.
Greatful for any help on this.
Yours, Johan

On Windows 9x:
The following line will work on the command prompt the way you want:
for %%i in (*.jar) do set CPATH=%%CPATH%%;%%i
But it simply doesn't work onto a batch file, and I couldn't get it working by that way. However, if you want this in a batch file, we can use your first idea, just a little different:
@echo off
if "%1"=="GoTo:" %1%2
SET CPATH=
for %%? in (*.jar) do call %0 GoTo: setvar %%?
goto eof
:setvar
SET CPATH=%CPATH%;%3
:eofThis script could require a big enviroment space, so it's a good idea to run it on a child shell with a big enviroment space:
@echo off
if "%1"=="GoTo:" %1%2
%comspec% /c call %0 GoTo: start
goto eof
:start
SET CPATH=
for %%? in (*.jar) do call %0 GoTo: setvar %%?
echo CPATH=%CPATH%
goto eof
:setvar
SET CPATH=%CPATH%;%3
:eofAfter running this last batch script, the CPATH won't have changed. That's because the variables are reset to their original state when a child shell of COMMAND.COM is terminated.
-- Secret_Doom - Leonardo Pignataro --
secret_doom@hotmail.com
www.batch.hpg.com.br

![]() |
![]() |
![]() |

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |