title: Loop through all media files in subdirectory
body: <p>I am currrently trying to loop through a couple of mp4 files and convert to a different format. The below works but it only converts one file and loop stops. Initially the files are in folder <code>videos</code> and as I convert i move to folder <code>formatted_vids</code>. How can i properly loop through all mp4 files? </p>
  
  <pre><code>FILE_PATH="/media/videos/"
   find $FILE_PATH -name "*.mp4" | while read file
           do
              filename=$(basename "$file")
              extension="${filename##*.}"
              video_file="${filename%.*}"
              dir="/media/formatted_vids/${filename%.mp4}"
              mkdir -p "$dir"
              mv "$file" "$dir"
  
              ffmpeg -i $dir/${filename} -c:a libfdk_aac -vbr 3 output.m4a "$dir/${filename%.mp4}-%03d.m4a";
  
          done
  </code></pre>
  
  <p>Initial Folder </p>
  
  <pre><code>|-- /media/videos/
      |   |-- xxxx-test_file-aa1
      |       |--xxxx-test_file-aa1.mp4
      |   |-- xxxx-test_file-bb2
              |--xxxx-test_file-bb2.mp4
  </code></pre>
  
  <p>Move files to Folder:</p>
  
  <pre><code>|-- /media/formatted_vids/
      |   |-- xxxx-test_file-aa1
      |       |--xxxx-test_file-aa1.aac
      |   |-- xxxx-test_file-bb2
              |--xxxx-test_file-bb2.aac
  </code></pre>