I’ve a file in c:\Program Files directory named tmp.txt
For each line in tmp.txt, I would like to execute a command.
I am trying to use command prompt for loop but it is not able to find the tmp.txt. Note that I’ve to run this command out of c:\Program Files directory.
Here is how I am trying:
C:\>for /F %i in ("c:\Program Files\tmp.txt") do echo "%i"
the output is:
C:\>echo "c:\Program"
"c:\Program"
which means that for is considering "c:\Program" as parameter and passing it to do
If I put file in c:\, and run for loop as-
C:\>for /F %i in (c:\tmp.txt) do echo "%i"
it works just fine
So my question is- how do I pass full path to for loop so that for consider it as file
Use the
usebackqoption tofor /f:This changes the semantics of the various quote characters, as the help states as well: