title: Batch Script - IF EXIST copy to %localappdata% error
body: <p>I seem to be stuck with a batch script and would like some help.</p>
  
  <p>Basically I need to check if a file exists in a folder in the <code>%localappdata%</code> and if it does then overwrite the file and if not place inside a different location so at the moment it reads like this:</p>
  
  <pre><code>IF EXIST "%localappdata%\foldername\filename" COPY /Y "filename" "location" ELSE COPY "filename" "location2" 
  </code></pre>
  
  <p>But when this runs I'm receiving an error of <code>The syntax of the command is incorrect.</code>  This seems to be down to the <code>%localappdata%</code> variable being used.</p>
  
  <p>Thank you in advance for any help on this.</p>