Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Concatenating files in Windows Command Prompt and the string ""

I am concatenating files using Windows. I have used the TYPE and the COPY command and I get the same artifact. At the place where my original files are joined in the new file, the character string "" (i.e. Decimal: 139 175 168 Hex: 8BAFA8) is inserted.

How can I troubleshoot this? Is there an easy explanation you can provide for how to avoid this. And why does this happen?

like image 652
P.Coltharp Avatar asked Feb 03 '26 10:02

P.Coltharp


1 Answers

The very good explanation why does this happen is in @Mark_Tolonen answer, so I will not repeat it.

Instead of obsolete TYPE and COPY one have to use powershell now:

powershell -Command "& { Get-Content a*.txt | Out-File output.txt -Encoding utf8 }"

This command get content of all files patterned by a*.txt in a current folder and concatenates them in the output.txt file using UTF-8.

Powershell is a part of Windows 7 and later.

like image 127
Sergey Avatar answered Feb 06 '26 01:02

Sergey



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!