Remove whitespaces from my merged batch file

0

I'm trying to merge multiple text files into one single file. The problem with the command below is that it creates several whitespaces in the final merged file content and can't have any spaces. How can I fix the script to remove all the whitespaces from the file content?

@echo off
For %%I in (*.txt) do (
  type %%I >> MERGED.tmp
  Echo. >> MERGED.tmp
)
REN MERGED.tmp MERGED.txt
Exit

Here is how it looks with the white spaces

Merged list containing with white spaces

This is the desired result

Merged list with no spaces

YOREL

Posted 2014-01-16T20:36:27.200

Reputation: 1

Are you referring to space in the file name, or white space in the file content? If file content, then you need to be more specific as to exactly what you want removed. An example of original source followed by desired output would probably help. – dbenham – 2014-01-16T21:03:54.363

The white space is in the file content. I have multiple text files containing a list of numbers and I trying to combine all these file into one single file. Ex text1.txt A00001L1 B00002L4 C00003L2 X00004L5 Z00005L3 The script Im using is adding a white space at the end of the last number when I merge it. – YOREL – 2014-01-17T15:04:37.583

Answers

0

Don't use type, use copy *.txt merged.txt. You can use quotation marks for filenames with spaces.

Thomas Weller

Posted 2014-01-16T20:36:27.200

Reputation: 4 102

The Copy *.txt creates a black arrow at the end and also put the first number of each list horizontally next to the last number of each list in the final merged. – YOREL – 2014-01-17T15:45:12.660