1

I am working on a project where I want to print several things to one line in a .txt file with multiple echo statements. For example I would want this:

 echo A
 echo B

To end up looking like this:

  AB

Instead of this:

  A
  B

How can I do this?

Yulap
  • 49
  • 2
  • 8
  • 1
    possible duplicate of [Windows batch: echo without new line](http://stackoverflow.com/questions/7105433/windows-batch-echo-without-new-line) – indiv Mar 13 '14 at 23:24

1 Answers1

3

You could use the set /p trick to output without a new line character.

>>file.txt (
    set /p "=A" <nul
    set /p "=B" <nul
)

You don't need to encase the statements in parenthesis, you can have them on separate lines if need be.

set /p "=A" <nul >>file.txt
REM Some thing that you don't want to output to file.txt
set /p "=B" <nul >>file.txt
unclemeat
  • 5,029
  • 5
  • 28
  • 52