title: Windows scripting FOR command to rename all files in a directory
body: <p>I am trying to rename all the files present in a Windows directory using <strong>FOR</strong> command as follows at the command prompt:</p>
  
  <pre><code>for %1 in (*.*) do ren %1 test%1 
  </code></pre>
  
  <p>E.g. This renames a file <strong>enc1.ctl</strong> to <strong>testenc1.ctl</strong> <strong>enc2.ctl</strong>  to <strong>testenc2.ctl</strong> </p>
  
  <p>Thats not what i want. What i want is 
  <strong>enc1.ctl</strong> renamed to <strong>test1.ctl</strong>   <strong>enc2.ctl</strong> renamed to <strong>test2.ctl</strong> </p>
  
  <p>How do i do that?</p>
  
  <hr>
  
  <p>@Akelunuk: 
  Thanks, that w kind of works but i have files names as </p>
  
  <p><strong>h263_enc_random_pixels_1.ctl , h263_enc_random_pixels_2.ctl</strong> which i want to rename to</p>
  
  <p><strong>test1.ctl and test2.ctl</strong> respectively </p>
  
  <p>Then how?</p>