import os import sys # # [ TD2 SCENERY PROCESSOR ] # by masuo # v1.2 # BAD_WORDS = ['Misc', 'Fence', 'TerrainPoint', 'Wires'] def should_exclude(line: str) -> bool: return any(bad_word in line for bad_word in BAD_WORDS) def process_file(file_path: str): if not file_path.endswith(".sc"): print(f"Skipping non-.sc file: {file_path}") return output_path = file_path[:-3] + ".lite.sc" print(f"Processing file: {file_path} -> {output_path}") try: with open(file_path, encoding="utf8") as infile, open(output_path, 'w', encoding="utf8") as outfile: for line in infile: if not should_exclude(line): outfile.write(line) except Exception as e: print(f"Error processing {file_path}: {e}") def process_directory(directory: str): print(f"Processing directory: {directory}") for entry in os.listdir(directory): full_path = os.path.join(directory, entry) if os.path.isfile(full_path): process_file(full_path) def main(): if len(sys.argv) < 2: print("Usage: python scp.py [ ...]") return for path in sys.argv[1:]: if os.path.isdir(path): process_directory(path) elif os.path.isfile(path): process_file(path) else: print(f"Invalid path: {path}") print("Done!") if __name__ == "__main__": main()