Batch Removing Newline in txt files in Windows Command line (cmd)

There are unnecessary new lines in txt files which i am merging during batch processing. I am thinking fof first removing all new lines and then inserting only one.

how can i do that in batch file


You can do the same as Idigas's answer (filtering non-empty lines) using the Windows built-in tool findstr:

findstr "." input.txt > output.txt

I don't know of a way to do it via cmd, since I always have done it via grep. grep is a part of unixkit-tiny, a rar archive of small tools that came to windows as a port from unix world. Just unrar and use, no installation necessary.

Removing lines:

grep . your_file.txt > your_file_without_empty_lines.txt

(this will copy all non blank lines from your_file.txt to a new file - lines which only have spaces in them are not considered blank)