Help on Grouping Commands in a Block
Posted: 28 Feb 2008 15:02
Hi,
I'm a newbie in writing batch files. Anyways I've got this code here which really confuses me...
@ECHO off
set "text2=about another."
echo %text2%
set text1=mharz
for /f "usebackq tokens=*" %%a in ("list.txt") do (
if %%a==%text2% (
echo %text2%
) else (
echo %%a
)
)
echo done.
goto :EOF
When I run the code above, this is the output:
about another. :: this is from echo %text2%
else was unexpected at this time. :: now, I don't understand this error here... Can anyone explain please???
Another weird thing is, when I change this line:
if %%a==%text2% (
to:
if %%a==%text1% (
it works perfectly fine!! Whats wrong with using text2???
text2 does look ok when I tried to output its value...
Do you know any workaround on this problem...?? I need text2 variable to have 2 or 3 words read as a single line.. Please help..
Thanks.
I'm a newbie in writing batch files. Anyways I've got this code here which really confuses me...
@ECHO off
set "text2=about another."
echo %text2%
set text1=mharz
for /f "usebackq tokens=*" %%a in ("list.txt") do (
if %%a==%text2% (
echo %text2%
) else (
echo %%a
)
)
echo done.
goto :EOF
When I run the code above, this is the output:
about another. :: this is from echo %text2%
else was unexpected at this time. :: now, I don't understand this error here... Can anyone explain please???
Another weird thing is, when I change this line:
if %%a==%text2% (
to:
if %%a==%text1% (
it works perfectly fine!! Whats wrong with using text2???
text2 does look ok when I tried to output its value...
Do you know any workaround on this problem...?? I need text2 variable to have 2 or 3 words read as a single line.. Please help..
Thanks.