Python: get all exe files in the current directory and run them?

First of all, this is not homework, I desperately need a script that will do the following: my problem is that I never had to deal with python, so I barely know how to use this - and I need it to run modular tests in TeamCity using a runner to build a command line

What I need is:

a * .bat that will run the script

python script that will be:

  • get all * _test.exe files in the current working directory
  • run all the files that were the result of the search

Regards

+3
source share
2 answers
import glob, os
def solution():
    for fn in glob.glob("*_text.exe"):
        os.startfile(fn)
+5
source

, script , .

import os       # Access the operating system.

def solution(): # Create a function for later.
    for name in os.listdir(os.getcwd()):
        if name.lower().endswith('_test.exe'):
            os.startfile(name)

solution()      # Execute this inside the CWD.
+3

Source: https://habr.com/ru/post/1749387/


All Articles