import subprocess # import glob import sys from pathlib import Path here = r"D:\code\public\gdal\swig\python\gdal-utils\osgeo_utils" scripts = list(Path(here).glob("**/*.py" )) for s in scripts: file = Path(s) if not 'gdal_auth.py' in file.name: r = subprocess.run([sys.executable, file], shell=True, capture_output=True, text=True, ) print(r.returncode, file)