title: Problems checking if string is quoted and adding quotes to string
body: <p>I am trying to check if a string is quoted by checking the first and last characters of the string.  But my script fails when checking for the quote see output: AND was unexpected at this time. below.</p>
  
  <p>Code</p>
  
  <pre><code>@echo off
  
  set mystring=Non quoted string
  
  set myquotedstring=^"My quoted string^"
  
  echo mystring: %mystring%
  
  echo myquotedstring: %myquotedstring%
  
  set result=%mystring:~0,1%
  
  echo first character of non quoted string is: %result%
  
  set result=%mystring:~-1%
  
  echo last character of non quoted string is: %result%
  
  if %mystring:~0,1%u==^" AND %mystring:~-1%==^" (
     echo this string is NOT quoted
     set newstring=^"Non quoted string^"
     echo newstring: %newstring%
  )
  
  set result=%myquotedstring:~0,1%
  
  echo first character of quoted string is: %result%
  
  set result=%myquotedstring:~-1%
  
  echo last character of quoted string is: %result%
  
  if %myquotedstring:~0,1%u==^" AND %myquotedstring:~-1%==^" (
     echo this string is quoted
  )
  </code></pre>
  
  <p>This is the output I am getting</p>
  
  <pre><code>mystring: Non quoted string
  myquotedstring: "My quoted string"
  first character of non quoted string is: N
  last character of non quoted string is: g
  this string is NOT quoted
  newstring: "Non quoted string"
  first character of quoted string is: "
  last character of quoted string is: "
  AND was unexpected at this time.
  </code></pre>
  
  <p>UPDATE</p>
  
  <p>I realise now I cannot use AND.  But even if I remove I have a problem.</p>
  
  <p>eg</p>
  
  <pre><code>if %mystring:~0,1%u==^" if %myquotedstring:~-1%==^" (
     echo this string is NOT quoted
     set newstring=^"Non quoted string^"
     echo newstring: %newstring%
  )
  </code></pre>
  
  <p>I get</p>
  
  <pre><code>The syntax of the command is incorrect.
  </code></pre>