Use Python instead of depending on OS infrastructure. This program could not run on Linux/Mac for example.
Here an example function to merge files:
Here an example function to merge files:
from pathlib import Path def merge_files(input_files: list[str | Path], output_file: str | Path) -> None: # user of code could supply a list with paths as str # or the paths as Path objetcs # but later Path objects are required, so all objects # are converted here input_files = [Path(file) for file in input_files] output_file = Path(output_file) # opening file in binary mode, which prevents encoding errors # if all input_files are encoded with the same encoding # Path objects do have the open method, which supports context managers with output_file.open("wb") as fd_out: # iterating over all input files for input_file in input_files: # same here, opening the input file in binary mode with input_file.open("rb") as fd_in: # https://realpython.com/lessons/assignment-expressions/ # read 4KiB chunks while chunk := fd_in.read(4 * 1024 ** 1): fd_out.write(chunk) # if the last line of input_file has no # lineseperator at the end, adding one to it # keep in mind, that everything is in binary mode # os.linesep is OS depended if not chunk.endswith(os.linesep.encode("ascii")): fd_out.write(os.linesep.encode("ascii"))
Almost dead, but too lazy to die: https://sourceserver.info
All humans together. We don't need politicians!
All humans together. We don't need politicians!