import os
import subprocess
from pathlib import Path

# Get the directory (current directory or specified)
#directory = Path.cwd()  # This gets the current working directory

# Or, if you want to specify a different directory, uncomment the line below:
# directory = Path("path/to/directory")

# List all files in the directory
#for file in directory.iterdir():
#    if file.is_file():
#	    #print(file.name)
#	    fn = file.name
#	    if fn.endswith(".elf") and not fn.startswith(("GML", "DOT", "json")):
#		    os.system(f"python3 FinalScript.py {file.name}")

counter1 = 1

for root, dirs, files in os.walk("."):
	for direc in dirs:
		for root2, dirs2, files2 in os.walk(os.path.join(root, direc)):
			for f in files2:
				#if f.is_file():
				#print(f)
				#fn = file.name
				if f.endswith(".elf") and not f.startswith(("GML", "DOT", "json")):
					#os.system(f"python3 FinalScript.py {f}")
					print(counter1)
					counter1 += 1
					try:
						subprocess.run(f"python3 FinalScript.py {f}", cwd=os.path.join(root, direc), shell=True, timeout=30)
					except subprocess.TimeoutExpired as e:
						print(e)