I want to concatenate multiple text files, that are encoded as UTF8+BOM, using a Windows 10 batch file. In between each file, I want to add a blank line. I used the TYPE command as shown below, but I found that since each file has a UTF-8 BOM on it, the resulting output file has BOMs in in the middle of it. I also tried the COPY command and it did the same thing.
ECHO -- File start >OUTPUT.TXT TYPE file1 >>OUTPUT.TXT ECHO( >>OUTPUT.TXT TYPE file2 >>OUTPUT.TXT ECHO( >>OUTPUT.TXT . . .
COPY header+file1+blankline+file2+blankline+... OUTPUT.TXT
I expected that TYPE would not echo the literal characters, but would instead use the BOM to determine the file encoding so that it could display the file correctly. Apparently not. :-( Does the TYPE command not understand Unicode at all? If it was a UTF-16 file would it really output nul characters between?
What is an alternative? Do I need to use PowerShell?