filebatch-file

Add Text To TXT File


I Don't Know How To Add Text To A .txt file. When I Do This

@echo off
echo te > file.txt
echo xt >> file.txt

The Text File Show's This:

te
xt

I Know That echo text >> filename.txt adds a line but I don't know how to make the batch file add text like this:

text

Solution

  • You can use a trick with the SET /P command.

    @echo off
    <nul set /p .=te>file.txt
    <nul set /p .=xt>>file.txt