title: Renaming a file after IF EXIST check within ++ FOR loop in a Windows batch file?
body: <p>I scoured the web and could not find the exact code I'm looking for... I found things that are very similar but did not get them to work. Here is a rough idea what I want:</p>
  
  <pre><code>int i = 1;
  FOR (i; i &lt; 9999; i++)
  IF EXIST filename.log THEN
  REN filename%i%.log
  ELSE IF EXIST filename%i%.log THEN
  REN filename%(i+1)%.log
  </code></pre>
  
  <p>Basically I want to check if a filename exists and if so, rename it to filename0001 -- from there on, each time the batch is run, if filename#### is found, it renames it to one after that. So of course after the first time this is run, when it finds that filename exists it will rename it to filename0002 and so on.</p>
  
  <p>Thank you!!</p>