title: String comparison in a batch script for loop
body: <p>I'm having issues with a simple piece of batch program in a for loop.</p>
  
  <p>basically, the program should for every file in a folder, if the file name begins with 'LOTTR' it should copy the file to the location Y:\ELCWork1-Rus. if not then it should be copied to Y:\ELCWork2-Oth. I've used 2 if's rather than an if..else for future substring comparisons...</p>
  
  <p>I need to compare an evaluated substring to a fixed value.
  In the code below - the logic always fails to match.  I've tried with and without double quotes and set the variable inside and outside the for loop.</p>
  
  <pre><code>@echo off
  setlocal ENABLEDELAYEDEXPANSION
  set %c=LOTTR
  for %%s in (*.csv) do ( 
     set tmp1=%%s 
     set vt1=!tmp1:~0,5! 
     set vt2=!tmp1:~0,55! 
     set "cmv=LOTTR"
     echo !tmp1:~0,10! 
     echo !vt1!
     echo %%c
     if /I "!vt1!"=="LOTTR" (
         echo "Matches"
         Xcopy !tmp1! "Y:\ELCWork1-Rus"
         )
     if /I NOT "!vt1!"=="LOTTR" (
         echo "No Match"
         Xcopy !tmp1! "Y:\ELCWork2-Oth"
         )
  
  )
  </code></pre>