Batch File to access multiple directories and execute python script in different command prompts

1

Hello everyone, how are you? I'm trying to create a bat file to run python scripts in different directories, something like this:

 C:\Test
    | --- Test1\example.py
    | --- Test2\example.py
    | --- Test3\example.py
 | --run.bat

I have several folders inside of Test, 'Test1', 'Test2' and 'Test3', I need to run them simultaneously with different command prompts, I got something like this:

@echo off
set back=%cd%
for /d %%i in (C:\Test\*) do (
start
cd "%%i"
python example.py
pause
cd %back%
)

But it only runs a script and goes back to the home directory, so I noticed, I believe it is running for only the first directory, any suggestions for this problem?

Thank you!

    
asked by anonymous 01.10.2018 / 15:05

1 answer

1

I was able to solve this problem, it follows the created .bat code:

@echo off
echo "this is the main batch script"
for /d %%i in (C:\Test\*) do (
start python "%%i\example.py"
)
pause
    
01.10.2018 / 17:30