title: how to increment text filename using batch script
body: <p>With reference to <a href="https://stackoverflow.com/questions/13328421/how-do-i-increment-a-folder-name-using-windows-batch">increment folder name link</a>, I want to ask how to change it from creating folder to creating text file?</p>
  
  <p>Here's the edited version of the code:</p>
  
  <pre><code>@echo off
  @For /F "tokens=1,2,3 delims=/ " %%A in ('Date /t') do @( 
      Set Day=%%A
      Set Month=%%B
      Set Year=%%C
  )
  
  @echo off
  setlocal enableDelayedExpansion
  set "baseName=testing-%Year%%Month%%Day%-"
  set "n=0"
  for /f "delims=" %%F in (
    '2^&gt;nul dir /b /ad "%baseName%*."^|findstr /xri "%baseName%[0-9]*"'
  ) do (
    set "name=%%F"
    set "name=!name:*%baseName%=!"
    if !name! gtr !n! set "n=!name!"
  )
  set /a n+=1
  md "%baseName%%n%"
  </code></pre>
  
  <p>So it works like this. "Hello-20140716-1", "Hello-20140716-2" etc folder can be created by double clicking this batch file. But how can I change it from folder to text file?</p>
  
  <p>I tried changing <code>md "%baseName%%n%"</code> to <code>Echo "Hello" &gt; %baseName%%n%.txt</code> and <code>Echo "Bye" &gt; %baseName%%n%".txt</code></p>
  
  <p>But this does not work as it will only output " Bye" into hello-20140716-1.txt without creating "Hello" to hello-20140716-1.txt and "Bye" to hello-20140716-2.txt</p>