title: Windows Batch Lame Encode syntax
body: <p>I need to get working properly a tiny Windows batch file (convert.cmd) that changes bitrate of all MP3 files in a specified folder.  I need to pass 2 parameters to the batch file:</p>
  
  <ul>
  <li>the path to the folder with MP3 files</li>
  <li>bitrate I want to change them to.</li>
  </ul>
  
  <p>I am using Lame.exe encoder. The lame.exe is in one place, convert.cmd can be in the same folder with lame.exe, but the folder with MP3 files can be anywhere. The original version (without parameters) was (and it's working fine if I place convert.cmd in the folder wit MP3 files):</p>
  
  <pre><code>@ECHO OFF
  FOR %%f IN (*.mp3) DO (
      D:\Apps\Lame\lame.exe -h -b 128 "%%f" "%%f.temp"
      DEL "%%f"
      REN "%%f.temp" "%%f"
  )
  PAUSE
  </code></pre>
  
  <p>Instead of 128 I need to pass "%2" and it will be a second command-line parameter, the bitrate, and for MP3 files folder path I need to pass "%1". <strong>So, I got this, but it's not working.</strong></p>
  
  <pre><code>@ECHO OFF
  FOR %%f IN (%1\*.mp3) DO (
      D:\Apps\Lame\lame.exe -h -b %2 "%%f" "%%f.temp"
      DEL "%%f"
      REN "%%f.temp" "%%f"
  )
  PAUSE
  </code></pre>
  
  <p>How to make it work as described?</p>
  
  <p>How can I ensure that my batch file convert existing files, and not creating new converted copies of them somewhere? Thanks a bunch ;) Cheers.</p>
  
  <p><strong>UPDATE</strong></p>
  
  <p>The location of convert.cmd is:</p>
  
  <p>d:\Apps\Lame\convert.cmd, same folder with lame.exe</p>
  
  <p>The location of MP3 files is:</p>
  
  <p>d:\temp\xxx\</p>
  
  <ul>
  <li>File1.mp3</li>
  <li>File2.mp3</li>
  </ul>
  
  <p>When I execute convert.cmd from the command line like this: </p>
  
  <p>convert.cmd d:\temp\xxx\ 64</p>
  
  <p>what I get in d:\temp\xxx\ is this:</p>
  
  <ul>
  <li>File1.mp3.temp</li>
  <li>File2.mp3.temp</li>
  </ul>
  
  <p>Where did the converted files go?</p>
  
  <p>Thanks.</p>