I’m merging two ASCII files via a simple batch script like this
COPY a.txt+b.txt c.txt /y /a
The problem is, the very last character in C gets set to 1A, the HEX notation for SUB. c.txt is fed into another executable which does not like the 1A at the end.
After c.txt is generated, if I open it up in Notepad++ and remove the last character, the file works fine.
How could I merge the a.txt and b.txt without 1A getting appended to the end of c.txt ?
The placing of
/aand/bswitches is critical. They perform differently depending on whether they are placed after the source filename(s) or the target filename.When used with a target filename,
/acauses the end-of-file marker (ASCII 26) to be added. You are actually specifying this!When used with the source filename,
/aspecifies the file is ASCII and it’s copied up to but not including the first ASCII 26 end-of-file mark. That character and anything after it is ignored./bcauses the entire file to be copied, including any end-of-file markers and anything after them.When used with the destination filename,
/acauses ASCII 26 to be added as the last character./bdoes not add ASCII 26 as the last character.Your solution
…although I haven’t tested it, is probably to use
COPY a.txt+b.txt /a c.txt /b /y