Solved delete blank line from a txt file using batch

May 30, 2011 at 05:09:19
Specs: Windows 7, 4gb
Hi Can any one help me here, i have a text file
30-05-2011 08:45:20
41
50
498
243
991
78
236
38
38
420
859
233
616
43
591
991
591
11
129
10
341
541
85
143

272985
17537
69
78
236
243
85
302

like this , i need to remove all empty lines from here . i tried this option already.
for /f "tokens=* delims= " %%a in (C:\log\DEVolap.log) do echo %%a>>DEVOLAP.txt
still it didnt work, it may be because of trailing spaces, can anyone help me plzzzzzzzzzzzzzzzzzzzzzzz.


See More: delete blank line from a txt file using batch

Report •

#1
May 31, 2011 at 00:26:28
✔ Best Answer
What about:

findstr /v /r /c:"^$" /c:"^\ *$" "C:\log\DEVolap.log" >> "DEVOLAP.txt"


Report •

#2
May 31, 2011 at 01:47:03
Thanks for ur help, but still i could see 1 blank line in the file, i think it may be because of trailing spaces, can u please suggest some other option to remove it.

Report •

#3
May 31, 2011 at 13:25:23
Perhaps a tab?

findstr /v /r /c:"^$" /c:"^\ *$" /c:"^\	*$" "C:\log\DEVolap.log" >> "DEVOLAP.txt"


Report •

Related Solutions

#4
May 31, 2011 at 22:36:03
Thank u Very much :)....

Report •

#5
June 1, 2011 at 00:27:49
It just occurred to me that if a line contains a mixture of spaces and tabs, but is otherwise blank that command above won't strip them out.

This should do it:

findstr /v /r /c:"^$" /c:"^[\ \	]*$" "C:\log\DEVolap.log" >> "DEVOLAP.txt"


Report •

Ask Question