Sep-03-2022, 09:58 AM
OK Folkes, been doing some surfing and found this bit of code.
Added my own with statement and come up with this....
How do I tell it to start a new file when the previous file has finished.
the file name would have to be changed for every file in the list.
Added my own with statement and come up with this....
path = r"My Path" path2 = r"My Path 2 with the file name of test2.text" for child in Path(path).iterdir(): if child.is_file(): print(f"{child.name},\n{child.read_text()}\n") with open(path2,"a") as f: f.write(child.read_text())I have the statement at the top of the scripts....
from pathlib import PathThis put all the files in the directory into 1 file.
How do I tell it to start a new file when the previous file has finished.
the file name would have to be changed for every file in the list.