db_run.py 532 B

12345678910111213141516171819
  1. from concurrent.futures import ThreadPoolExecutor
  2. from pathlib import Path
  3. import subprocess
  4. def task(name):
  5. print(Path(name).name)
  6. return subprocess.Popen(f'C:\\Windows\\System32\\cmd.exe /C "{name}"', stdout=subprocess.DEVNULL).wait()
  7. def main(base_dir):
  8. files = [str(f) for f in Path(base_dir).glob('*.bat') if not f.name.startswith('_')]
  9. with ThreadPoolExecutor(max_workers=5) as executor:
  10. executor.map(task, files)
  11. if __name__ == '__main__':
  12. main('C:\\GlobalCube\\System\\CARLO\\SQL\\batch')