views:

27

answers:

1

HI,

I want to display datas in text file. Here i have Listfile.txt and want to display each line using batch file. How to do this with looping. Below is my code

for /f "tokens=* delims= " %%a in (Listfile.txt) do (
  set /a N+=1
  set v!N!=%%a
)
set hostname=!v1!
echo %hostname%
pause

Data in Listfile.txt:

4mLinuxMachine.cpp
ShutdownPanel.cpp
windows.cpp

How to display each using hostname variable

Please help

A: 

If you just want to display each line of the text file, try this:

FOR /F "tokens=1"  %%a IN (Listfile.txt) DO (
  ECHO %%a
)
aphoria
My intention is to store in each line in hostname and hav eto print in for loop
Side note: This will loop over every *non-empty* line in the file.
Joey