title: Apply a command for each file in a folder using Windows batch script
body: <p>I am trying to figure out how to create a script that will take all video files in a folder videos\*.* and then use ffmpeg on each one and output the files to converted\*.mp4 where the filenames are the same.</p>
  
  <p>However, I can't figure out how to get the <code>for</code> loop working, so that I can extract the name and extension type of file I am processing.</p>
  
  <pre><code>for %%f IN (videos\*.*) DO (convert.bat %%f)
  </code></pre>
  
  <p>convert.bat</p>
  
  <pre><code>ffmpeg.exe -i %1 -f mp4 converted\%~n.mp4
  </code></pre>
  
  <p>I have tried both with and without double quotes. However, it won't recognise the file.</p>