title: Using FOR loops to check file exist
body: <p>I'm trying to use FOR loops to create a batch that checks if file exists in a directory. I'm struggling with files that has spaces with the file name and i don't want to have to use a .txt list if possible. So here is what i have tested so far.</p>
  
  <pre><code>@echo OFF
  :: Variables
  set Folder=D:\Test Folder
  set Space=File Name With Space.txt
  set NoSpace=FileNameWithoutSpace.txt
  
  :: For Loop
  
  FOR %%A in (%Space% %nospace%) do (
  if exist "%Folder%\%%A" (
          ECHO %%A exist
          ) else (
              ECHO %%A doesn't exist
              echo. )
  )
  </code></pre>
  
  <p>Here is what it reads when turned echo back on.</p>
  
  <blockquote>
    <p>(if exist "D:\Test Folder\File" (ECHO File exist )  else ( ECHO File
    doesn't exist   echo.   ) )</p>
  </blockquote>
  
  <p>And if i use this code:</p>
  
  <pre><code>@echo OFF    
  :: Variables
  set Folder=D:\Test Folder
  set Space="File Name With Space.txt"
  set NoSpace=FileNameWithoutSpace.txt
  
  :: For Loop
  
  FOR %%A in (%Space% %nospace%) do (
  
  if exist "%Folder%\%%A" (
      ECHO %%A exist
      ) else (
          ECHO %%A doesn't exist
          echo. )
  )
  </code></pre>
  
  <p>It reads the "IF" command as:</p>
  
  <blockquote>
    <p>(if exist "D:\Test Folder\"File Name With Space.txt"" (ECHO "File Name
    With Space.txt" exist )  else ( ECHO "File Name With Space.txt"
    doesn't exist    echo.   ) )</p>
  </blockquote>
  
  <p>What am I doing wrong?</p>