[comp.sys.ibm.pc] Nestled Batch Files Under MS-DOS

harty@cg-atla.UUCP (09/17/87)

     I wish to execute a batch file from  within  in  a  for
loop of another batch file.

    f00.bat

         for %%1 %%2 %%3 in (*.plt) do ( f001.bat)


     The problem is that f001.bat is executed once and  does
not  return  to  f00.bat.  I have heard a rumor about a work
around in "config.sys" or something but could not  find  any
documentation.

     Could someone either mail to me at decvax!cg-atla!harty
or post a solution if there is one ?

                      thanx

                       kjh

gkb@necntc.NEC.COM (Greg Busby) (09/18/87)

In article <874@cg-atla.UUCP> harty@cg-atla.UUCP (Kevin Harty) writes:
>
>     I wish to execute a batch file from  within  in  a  for
>loop of another batch file.
>    f00.bat
>         for %%1 %%2 %%3 in (*.plt) do ( f001.bat)
 
 
>     The problem is that f001.bat is executed once and  does
>not  return  to  f00.bat.  I have heard a rumor about a work
>around in "config.sys" or something but could not  find  any
>documentation.
 
>     Could someone either mail to me at decvax!cg-atla!harty
>or post a solution if there is one ?
>                       kjh


The solution is very simple, given in the April '87 _Computer Language_.

Simply precede the call to the second batch file by 'command /c' and you
force DOS to load another copy of the command interpreter which is being
run by the first copy.  When this copy exits, it returns to the first
copy and hence to your original batch program.  I have used this
successfully a number of times, although I have never nested more than
one level (although I would assume that it would work for more).

In your example, 

	for %%1 %%2 %%3 in (*.plt) do command /c foo1

Good luck.

GKB

guardian@laidbak.UUCP (Harry Skelton) (09/19/87)

In article <874@cg-atla.UUCP> harty@cg-atla.UUCP (Kevin Harty) writes:
>
>     I wish to execute a batch file from  within  in  a  for
>loop of another batch file.
>
>    f00.bat

Have you tried something like :
                                          vvvvvvvvvv
>         for %%1 %%2 %%3 in (*.plt) do ( command /c f001.bat)
>
>                      thanx
>
>                       kjh


I know if you wish to batch commands that you have to use command.com to 
'shell' over what your are working with.  Look it up.  It works for me.

                          .---------.
Harry Skelton             :   .-.   : --- other mail drops ---
guardian@laidbak.UUCP     :   `-'o  : ihnp4!laidbak!ugh!bear
ihnp4!laidbak!guardian    :    O    : ihnp4!chinet!guardian
                          `---------' 
                    ,                      ... 
The epic Battle     `--,---.//"[       ]-^/   \------*
 Continues !!         \_    :.          .=   .=

aja@i.cc.purdue.edu (Mike Rowan) (09/19/87)

>                                           vvvvvvvvvv
> >         for %%1 %%2 %%3 in (*.plt) do ( command /c f001.bat)
> >
> I know if you wish to batch commands that you have to use command.com to 
> 'shell' over what your are working with.  Look it up.  It works for me.
 
     and if you get dos 3.3 you can just say 
	 for %%1 %%2 %%3 in (*.plt) do (call foo.bat)

  cool beans.

-mike