title: How do I increment a filename in batch?
body: <p>I am programming a batch file that can track lost android phones using the google maps geolocation API. I cannot understand what is wrong with my code. I followed everything I found on the internet but if I run the code, it returns "the syntax was incorrect" or something like that.It basically increments a filename if the basename exists. Can you show me what is wrong with my code and how do I correct it?</p>
  
  <pre><code>:MainProcessNew
  cd C:\Users\%USERNAME%\Documents
  for %%G IN (*.json) do (
  set file = %%G
  )
  set "baseName=data"
  set "n=0"
  
  :loop
  set /a n+=1
  if exist "%baseName%%n%.json (
  goto loop
  )
  
  echo.&gt;"C:\Users\%USERNAME%\Documents\data%n%.json"
  </code></pre>