Would you like to learn how to read a text file using the command line? In this tutorial, we are going to show you how to use Batch scripts to read a line from a text file on a computer running Windows.

• Windows 2012 R2
• Windows 2016
• Windows 2019
• Windows 10
• Windows 11

Equipment list

Here you can find the list of equipment used to create this tutorial.

This link will also show the software list used to create this tutorial.

Windows Related Tutorial:

On this page, we offer quick access to a list of tutorials related to Windows.

Batch Script - Read lines from a text file

Start a command-line prompt.

Windows - Command-line prompt

Create a text file.

Copy to Clipboard

In our example, we created a text file named MYFILE in the root of drive C.

Read lines from a text file using a Batch script.

Copy to Clipboard

Here is the command output.

Copy to Clipboard

Congratulations! You are able to read from a text file using a Batch script.