Hi i would like to run add1.py and add2.py simultaneously and have searched BAT file and SH file but couldnt do it myself. Anyone can help me? The folder is in the following path C:UsersJiaDownloadsTelegram BotScripts
I might also add more scripts like add3.py add4.py and the list goes on. Does anyone have simple tips that can help me run every script in this folder? Thank you!
It would be even better if the script runs one after another, example add2.py runs after add1.py finishes.
3
Answers
Just run:
python add1.py & python add2.py
. If you only want the second one to run if the first executes successfully, usepython add1.py && python add2.py
.Running them at the same time would use something called concurrency, which would require some modifications to your script.
NOTE: This will only work on Windows. On Linux or MacOS, you would use:
python add1.py ; python add2.py
You can manually add more scripts. To runn every python file in a folder, you could use:
python *.py
if you imported them all as modules into a new file calledmain.py
and executed them in what ever order you like in that file.You can try this, if you are just tying to run python file:
Or if the name has some pattern or it is sure then, try this:
As someone else already suggested, you could make a python file which executes your N python scripts.
Using
subprocess
as described here: https://stackoverflow.com/a/11230471/11962413