title: For loop recursively through folder in windows cmd for file rename
body: <p>I'm trying to iterate through folders with images to create thumbnails using ImageMagic, and rename thumbnail files with <code>small_</code> prefix.</p>
  
  <p>when I execute this in single folder, it works great:</p>
  
  <pre><code>FOR %a in (*.jpg) DO convert %a -thumbnail 30% small_%a
  </code></pre>
  
  <p>To loop through subfolders, I just need /R flag:</p>
  
  <pre><code>FOR /R %a in (*.jpg) DO convert %a -thumbnail 30% small_%a
  </code></pre>
  
  <p>This will result into new name for thumbnail 
  <code>small_c:\images\image.jpg</code> which is wrong :)</p>
  
  <p>How can I get <code>small_</code> prefix into file name while recursing through subfolders in script, i.e. from <code>c:\images\image.jpg</code> to <code>c:\images\small_image.jpg</code> ?</p>
  
  <p>Thanks. </p>