Dhiwakar Ravikumar
Dhiwakar Ravikumar

Reputation: 2217

How to ECHO "complex" paths using batch files?

I'm using the term "complex" very lightly since the paths themselves are not difficult to parse but I'm facing an issue anyway.

If I try to echo the following statements, It fails & I can't figure out why.

FOR /L %%G IN (1,1,5) DO (
echo name:sc%%G >> create.txt
echo Q:\sc%%G >> create.txt
echo DHIWAKAR-PC:sc%%G:F >> paths.txt
) 

If I replace the above piece of code with the one below, things are fine. Unfortunately, it also prints the quotes (""). Is there anyway to avoid this ?

FOR /L %%G IN (1,1,5) DO (
echo "name:sc%%G" >> create.txt
echo "Q:\sc%%G" >> create.txt
echo "DHIWAKAR-PC:sc%%G:F" >> paths.txt
) 

Upvotes: 1

Views: 68

Answers (1)

npocmaka
npocmaka

Reputation: 57282

FOR /L %%G IN (1,1,5) DO (
 (echo(name:sc%%G)>> create.txt
 (echo(Q:\sc%%G)>> create.txt
 (echo(DHIWAKAR-PC:sc%%G:F)>> paths.txt
)

the first may be fails because the digits are taken for streams numbers.

Upvotes: 4

Related Questions