Consider this as the contents of a
@echo off set test1=hello echo 0 %test1% for %%F in ( *.txt ) do ( set test2=%%F echo 1 %test1% echo 2 %test2% echo 3 %%F ) pause
When I run this script in Win 7 from a folder containing a.txt and b.txt as the only .txt files, I get this:
0 hello 1 hello 2 3 a.txt 1 hello 2 3 b.txt Press any key to continue . . .
All the "successful" echo commands (starting with 0, 1 and 3) are proof that the echo and variable syntax are correct. The "unsuccessful" echo command (2) can only be the result of an unsuccessful SET command. How? Why? What SET command syntax do I need so that the
test2 variable is assigned correctly, and the output lines starting with 2 are identical to those starting with 3?