Solved how i can make a batch file read a txt file?

October 11, 2020 at 11:44:23
Specs: Windows 10, Intel(R) Core(TM) i5-4210U CPU @ 1.70GHz 2.40 GHz/4,00 GB DDR3
like i want to create an login/register script (if its possible to do) but i don't know how to read text or change text in txt files on batch
can you help me please?

message edited by Maxly


See More: how i can make a batch file read a txt file?


#1
October 11, 2020 at 14:51:11
✔ Best Answer
Hi, here is a basic example to read a text file & display the results:

@REM Variables
set my_file="C:\temp\my_sample_file.txt"

@REM Read 1 line at a time from the file & display the line
for /f %%a in ('%my_file%') do echo %%a

message edited by Shell_L_D


Reply ↓  Report •

#2
October 11, 2020 at 21:01:42
To change contents of text file, you have to "read" each line, make any changes, then write the line out to a temp file. Then, at your option, you can copy it back over the original.

Reply ↓  Report •
Related Solutions


Ask Question