title: Using batch process to encode multiple files one at a time with ffmpeg
body: <p>Total beginner here, likely asking for help on something (hopefully) very easy to implement.</p>
  
  <p>I have a drop folder set up to trigger a batch process that will encode any videos contained therein to 5 different formats using FFMPEG. It also creates a text file containing the files name which I then use in a separate php/api process to upload the videos to the internet. </p>
  
  <p>The process works perfectly when just the one video is dropped into the drop folder. However, as soon as there are two or more then the process comes unstuck. </p>
  
  <p>Here's an example of one of the ffmpeg scripts the batch file runs:</p>
  
  <pre><code>for %%a in ("C:\live\dropfolder\transcode\*.*") do ffmpeg\ffmpeg -i "%%a" (encoding settings) "C:\live\dropfolder\output\%%~na.mp4"
  pause
  for %%g in (C:\live\dropfolder\output\*.mp4) do echo %%~nxg &gt; C:\live\dropfolder\filename\filename_format.txt
  </code></pre>
  
  <p>So when there are 2 or more files, the filename that gets generated by that echo might be for File A, while the transcoding session might have been for File B. </p>
  
  <p>Ideally I'd like to have the whole process finish transcoding the first video - including generating the text files for each format - before returning to the beginning of the process for the next video in the drop folder.</p>
  
  <p>How do I achieve this? Any suggestions would be greatly appreciated.</p>
  
  <p>Thanks!</p>
  
  <p>Tom </p>