Search code examples
pythonautomation

How to make a python script to run other files in separate terminals?


I made some scraping files and to run them at the same time I usually open multiple terminals in VS code and write " python filename.py " for each file, there's any method to automate this process to call each file and run it?


Solution

  • I think the terms "Automation" and "each time I call it and run it" you have used to ask for running it automatically within the program or by a python script. For that you just simply use one module "OS MODULE"

    import os
    path = r'paste the path of the files'
    filename = ['\file1.py', '\file2.py']
    for file in filename:
        os.system('python '+path+file)
    

    This code runs two files. Hope it helps