Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Display the contents of a .txt in a batch file?

Tags:

batch-file

I am working on a batch file right now and I have everything done that I need but I'm stuck at one point. One of the programs I use spits out a log file and I have it place this file on the C:drive in a folder. What I want to do is have it read this .txt and spit that back into the batch file as an echo.

like image 210
Szcwczuk Avatar asked Jul 07 '12 22:07

Szcwczuk


People also ask

How do I run a TXT file in a batch file?

For the file name, type test. bat and if your version of Windows has a Save as type option, choose All files, otherwise it saves as a text file. Once you have completed these steps, click the Save button and exit notepad. To run the batch file, double-click it like any other program.

How do I read the contents of a batch file?

Using a BAT file in Windows is as simple as double-clicking or double-tapping it. You don't need to download any special program or tool. To use the first example from above, entering that text into a text file with a text editor and then saving the file with the .

What does %% do in batch file?

Use double percent signs ( %% ) to carry out the for command within a batch file. Variables are case sensitive, and they must be represented with an alphabetical value such as %a, %b, or %c. Required. Specifies one or more files, directories, or text strings, or a range of values on which to run the command.

How do I write the output of a batch file?

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.


1 Answers

You can put this in your batch file:

type C:\folder\test.txt

This will echo out the contents of test.txt.

like image 173
user1509341 Avatar answered Sep 22 '22 03:09

user1509341