0

I am trying to read a file line by line from .bat file.

@echo off
for /F "tokens=*" %%A in  (instance2.txt) do (
 echo %%A
 set line=%%A
 echo %line%
)

echo ******end******

The problem is that every time it is printing the last line only. please help me sort out the problem. Thanx in advance.

Amit.

Amit
  • 21
  • 1

1 Answers1

0

you need a delayed expansion:

@echo off
setlocal enableDelayedExpansion
for /F "tokens=* delims=" %%A in  (instance2.txt) do (
 echo %%A
 set "line=%%A"
 echo !line!
)

echo ******end******
npocmaka
  • 55,367
  • 18
  • 148
  • 187