Matt Alhonte
06/23/2023, 10:54 PM.py
file into the folder").
import os
import subprocess
from pathlib import Path
from shutil import copy
starting_dir = Path(
"" # Put the folder with the Flows here
).resolve()
all_scripts = list(starting_dir.glob("*.py"))
for script in all_scripts:
without_extension = str(script).split(".")[0]
folder = without_extension.split("/")[-1]
just_script = f"{folder}.py"
folder_path = Path(starting_dir, folder)
Path(folder_path).mkdir(parents=True, exist_ok=True)
new_script_path = Path(folder_path, just_script)
copy(script, new_script_path)
os.chdir(folder_path)
subprocess.run(["python", new_script_path])