Feb-05-2019, 12:53 AM
I figured this out a while ago. Thought I would share the solution for future browsers/google searchers:
file_count = 0 count = 0 def write_file(): global file_count, count, sfile if(count > 0): call_close() file_count += 1 count = 0 else: call_close() count += 1 def call_close(): global file_count, ffilename with open(f"{wrkDir}\\sfile{file_count}.txt", "a+") as text_file: text_file.write("file ") text_file.write(f"'{clipOrig}\\{ffilename}'") text_file.write("\n") text_file.close()