1

I am creating a .bat file, that creates and writes code to another .bat file.

The problem is, it always leaves a blank line in the end. My code is:

ECHO ^@echo off> fb.bat
ECHO echo This is a>> fb.bat
ECHO test>> fb.bat
ECHO file>> fb.bat

And the output is like:

 @echo off
 echo This is a
 test
 file
 

How can I prevent it from creating a blank line in the end?

Cody Coderson
  • 411
  • 1
  • 9
  • 21
  • 5
    When I run your code, I get 4 lines output. I don't see how your code is producing a 5th line at the end with any data on it. After I run your batch file I then confirmed it with the find command: `find /c /v "" fb.bat` And the output was: `---------- FB.BAT: 4` – Squashman Nov 19 '16 at 18:12

1 Answers1

0

I just needed to use:

echo | set /p dummyName="last line code/text">> fb.bat

At the last line. In my case:

echo | set /p dummyName="file">> fb.bat

Would do the trick.

Cody Coderson
  • 411
  • 1
  • 9
  • 21
  • 5
    The final carriage return / line feed (CR/LF) is considered the end of the final line, not the beginning of a new one. This code does prevent the (CR/LF) on your last line, but your original code does not have an empty 5th line - It just has 4 lines, each with terminating (CR/LF). – dbenham Nov 19 '16 at 19:22