import os # Walk through all directories and subdirectories from the current directory for dirpath, dirnames, filenames in os.walk('.'): # For each file in the directories for filename in filenames: # If the file is a .sy file if filename.endswith('.sy'): filepath = os.path.join(dirpath, filename) with open(filepath, 'r') as file: lines = file.readlines() # Remove lines containing '#include "sylib.h"' lines = [line for line in lines if '#include "sylib.h"' not in line] with open(filepath, 'w') as file: file.writelines(lines)