Tuesday, April 23, 2013

Echo a new line in .BAT files

To echo an empty line in batch file, write dot character right after echo command (no space in between!):
@echo off
echo Next line is empty:
echo.
echo Press any key to continue...
Same result:
@echo off
echo Next line is empty: & echo.
echo Press any key to continue...
And in one line:
@echo off
echo Next line is empty: & echo. & echo Press any key to continue...

3 comments:

  1. Replies
    1. @echo off
      :: New line
      set "NL=&echo:"
      color 2F
      (
      ECHO ._%time:~0,8%
      ECHO [ SAMPLE _ FOR New LINE ]
      ECHO LINE 1
      ECHO LINE 2
      ECHO LINE 3
      )
      :: OR Using "NL" definition

      ECHO ._%time:~0,8% %NL%[ SAMPLE _ FOR New LINE ]%NL%LINE 1%NL%LINE 2%NL%LINE 3
      :: wait
      ping 0 -n 8 > nul

      Delete
    2. @echo off
      :: New line
      set "NL=&echo:"
      color 2F
      (
      ECHO ._%time:~0,8%
      ECHO [ SAMPLE _ FOR New LINE ]
      ECHO LINE 1
      ECHO LINE 2
      ECHO LINE 3
      )
      :: OR Using "NL" definition

      ECHO ._%time:~0,8% %NL%[ SAMPLE _ FOR New LINE ]%NL%LINE 1%NL%LINE 2%NL%LINE 3
      :: wait
      ping 0 -n 8 > nul

      Delete