Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

running all the batch files in a given directory

I have the following batch script for running all the files in a directory .However this script is an infinite loop and keeps on repeating . is there a way to stop the script when it finishes the last batch file the following is my script

@echo off 
 for /R %%x in (*.bat) do ( 
 call "%%x" 
)
pause
like image 256
Sarthak Bansal Avatar asked Dec 12 '25 05:12

Sarthak Bansal


1 Answers

Since you're including this script in your current directory, it is run with the others: recursive/infinite call.

Either put this script one level up, cd in the directory of the bat files and call it with ..\yourscript.bat

Or you could filter out the current script in your loop:

@echo off 
 for /R %%x in (*.bat) do (
 if not "%%x" == "%~0" call "%%x" 
)
like image 109
Jean-François Fabre Avatar answered Dec 14 '25 01:12

Jean-François Fabre