title: Batch File to insert char in file name for multiple files in a folder
body: <p>I have a series of files that have names like this:</p>
  
  <pre><code>CHART_LOAN_6516_20130502.PDF
  
  CHART_LOAN_2158_20130502.PDF
  
  CHART_LOAN_78986_20130502.PDF
  </code></pre>
  
  <p>Each file always starts with CHART_LOAN_ but the next number is different and the last number is the date it was created.</p>
  
  <p>I would like to insert an 0_ after CHART_LOAN_number_ for each file. As listed below:</p>
  
  <pre><code>CHART_LOAN_6516_0_20130502.PDF
  
  CHART_LOAN_2158_0_20130502.PDF
  
  CHART_LOAN_78986_0_20130502.PDF
  </code></pre>
  
  <p>Through my research I've found out to insert the char but not when the name is changing with each file.</p>
  
  <pre><code>@echo off
  SETLOCAL ENABLEDELAYEDEXPANSION
  SET old=CHART_LOAN_
  SET new=CHART_LOAN_0_
  for /f "tokens=*" %%f in ('dir /b *.jpg') do (
    SET newname=%%f
    SET newname=!newname:%old%=%new%!
    move "%%f" "!newname!"
  )
  </code></pre>
  
  <p>The above code will change the static portion of the file to something I want, but I don't know how to modify the code to compensate for the changing loan number.</p>