remove blank line - windows 7 scripting - to avoid "Echo is off"

hi

I have basic query regarding Windows Scripting on Windows 7 command prompt.

there is batch like below.

@ECHO off
FOR /F "usebackq eol=; delims=" %%i IN ("file.sql") DO (

IF NOT "%%i" EQU "" ECHO %%i >> test.txt
)

ECHO;
ECHO ********************************
pause


input file.sql has multiple blank lines, which will resulted to see lines like this.
ECHO is off.

I would like to avoid this case, would somebody please help to advice how I can simply skip blank line so that "ECHO is off." will not be printed?



@ECHO off FOR /F "usebackq eol=; delims=" %%i IN ("file.sql") DO ( IF NOT "%%i" EQU "" IF NOT "%%i" EQU " " ECHO %%i >> test.txt )
1: 2: 3: 4:

Select allOpen in new window



If %%i begins with a SPACE character, that would happen.



thanks, how can I skip that case, a space in addition to blank within this windows script?



@ECHO off FOR /F "usebackq eol=; delims=" %%i IN ("file.sql") DO ( IF NOT "%%i" EQU "" IF NOT "%%i" EQU " " ECHO %%i >> test.txt )
1: 2: 3: 4:

Select allOpen in new window



Simple fix: use "echo.%%i" (note the dot instead of a space after the "echo").
In addition, you're adding a space at the end of each line with the "ECHO %%i >> test.txt" (and you should probably delete test.txt at the beginning of the script).
Try it like this:



Dear NewVillageIT, oBdA

Thank you very much to both for support! It works perfectly!!

Thanks Regards

Share this

Related Posts

There was an error in this gadget