-4

What I got is a list of bat files:

  • file1.bat
  • file2.bat
  • file29.bat

I need them to run one after each other. Meaning when the file1.bat closes file2.bat starts and so on.

I tried this, but it doesn't work properly:

start /wait call file1.bat 
start /wait call file2.bat
David Makogon
  • 69,407
  • 21
  • 141
  • 189
Saul
  • 1

2 Answers2

0

You might want to add more to your question to make it easier to understand. My guess is that you want the bat file to open the next one then close itself after that.

If that's what you want to do; add these commands to each of the files:

start file2.bat
exit

Of course, you'll want to change start file2.bat to start file3.bat and so on for each file.

If you want file1.bat to manage all of the files, I don't think that's possible in batch.

GreenJames
  • 21
  • 1
  • 8
  • No, it's not what I meant. I mean. There's a folder with multiple bat files. Each and everyone of them converts a video file. They close automatically, so I don't have to worry about it. What I need is for them to open one by one. First file1.bat closes , file2.bat opens automatically. That's the problem :) – Saul Aug 20 '16 at 17:33
0

You didn't describe how exactly it's not doing what you expected. I'm guessing that what happens is you're having to shut down each script before the next one will continue.

Documentation on start says:

WAIT        Start application and wait for it to terminate.
command/program
            If it is an internal cmd command or a batch file then
            the command processor is run with the /K switch to cmd.exe.
            This means that the window will remain after the command
            has been run.

If you must use start then you could force it to use the /c switch which will automatically close the window once it's done:

start /wait cmd /c call file1.bat

I'm not really sure you accomplish anything by using call so that ought to be equivalent to just:

start /wait cmd /c file1.bat

Using start creates a new window for each program and you may just want to have it all run in a single command processor window.

As noted by Biffin you can just list them all out in a master script and they will run in order.

call file1.bat
call file2.bat
...
call file29.bat

And a shorthand for that is:

for /l %%f in (1; 1; 29) do call file%%f.bat

Remember to double up those percent characters inside a batch script but not on the command line.

This question might explain some of the unexpected behavior you were seeing.

How to run multiple .BAT files within a .BAT file

Community
  • 1
  • 1
shawnt00
  • 16,443
  • 3
  • 17
  • 22