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

mangusbrother
  • 3,988
  • 11
  • 51
  • 103
  • You may read full details on this management at http://stackoverflow.com/questions/10166386/arrays-linked-lists-and-other-data-structures-in-cmd-exe-batch-script/10167990#10167990 – Aacini Oct 28 '15 at 23:04

1 Answers1

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
)
wOxxOm
  • 65,848
  • 11
  • 132
  • 136