Remove empty line using batch command

November 15, 2011 at 00:59:31
Specs: Windows XP
Hi,

I am having data file like below, where there are lot of empty lines (only separates are there). I want to remove those empty line using some batch command. Can you please help. Also I am trying to avoid to read line-by-line as the actual files are having million of lines.

1,,3,abc,ac,aw,q
1,2,3,,,,q
1,2,qq3,abc,4ac,2aw1,q
,,,,,,
,,,,,,
,,,,,,
,,,,,,
,,,,,,
,,,,,,
,,,,,,
,,,,,,
,,,,,,
,,,,,,

Thanks in advance for the help.


See More: Remove empty line using batch command

Report •

#1
November 15, 2011 at 03:16:19
In order to identify the selected lines it has to be read.

Report •

#2
November 15, 2011 at 03:57:09
Maybe just use findstr, but it will still read the file:

findstr /v /r "^\,*$" "oldfile" > "newfile"


Report •

#3
November 16, 2011 at 17:54:56
This is another way. It too reads the file line by line but with batch scripting thats the only way its going to work. Perhaps try the vbscript forum for the result you are looking for.

for /f %%A in (oldfile) do (if NOT "%%A"==",,,,,," (echo %%A>>newfile))


Report •
Related Solutions


Ask Question