lundi 20 avril 2015

Reading a variable in a for loop in a bat file

I am trying to print lines from a file in the below for loop:

SET my-file="C:\tmp\xxx.txt"
@echo off
for /f "tokens=*" %%a in (%my-file%) do (
  echo line=%%a
)

Where: C:\tmp\xxx.txt contains:

a
b
c
d

But the %my-file% is not expanded. How do I use a variable in the for loop?

Aucun commentaire:

Enregistrer un commentaire