0

I have the following snippet

setlocal EnableExtensions EnableDelayedExpansion
SET copyableTomcat="C:\test\source"
SET tomcatNode[2]="C:\test\source"

set x=2

IF %copyableTomcat% == %%tomcatNode[%x%]%% (
    call echo "ignoring " %%tomcatNode[%x%]%%
) ELSE (
    call echo "done"
)

However, the if statment is NEVER matching, and always goes into the else statement.

I am unsure if i am mistypying something or missing something completely

1

1 Answer 1

2

%%var%% only works with call.

  • Use ! to expand the value since you're already using delayed expansion
  • No need for quotes in echo
  • No need to use call with delayed expansion in this case

IF %copyableTomcat%==!tomcatNode[%x%]! (
    echo ignoring !tomcatNode[%x%]!
) ELSE (
    echo done
)
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.