Windows 10

Batch File To Write To a Text File

In this tutorial, we are going to see how to write to a text file by using ECHO and redirecting the output to a text file. The batch file contains a series of DOS (Disk Operating System) instructions. It allows triggering the execution of commands found in this file.
 

Batch File To Write To a Text File

The following example write two line into “file.txt”:
 

 

@echo off
 
echo Hello, Welcome To StackHowTo> file.txt
echo The First eLearning Platform.>> file.txt

Output:
 

 

  • The > operator is used to overwrite any file that already exists with new content.
  • The >> operator is used to append to the text file (add to), instead of overwriting it.

 

Leave a Reply

Your email address will not be published. Required fields are marked *