Is there a way to batch covert a folder of .mkv files to .m4v files using ffmpeg in Mac?

I setup a service that will do individual files, but I really would like to batch them.

The 'Run Shell Script' that I'm using is:

for f in "$@"
    /Users/username/Movies/ffmpeg -i "$f" -c:v copy -c:a copy "${f%.*}.m4v"

Here is a screen shot of what I have that works for individual files:

enter image description here


@ldiastx, please take a look:

for f in *.mkv;do ffmpeg -i "$f" -c:v copy -c:a aac -b:a 256k "${f%mkv}mp4";done

Or if you don't need to re-encode:

for f in *.mkv;do ffmpeg -i "$f" -c copy "${f%mkv}mp4";done

If you want to put the new files in a separate directory:

mkdir output
for f in *.mkv;do ffmpeg -i "$f" -c:v copy -c:a aac -b:a 256k "output/${f%mkv}mp4";done
  • Dude: I am struggling with this a bit. The name of my files are this format.... tvshow s01e01 - name of tvshow.mkv my script still will do individual files within the folder. I just right click the file and look under services and then select the name of my service that i created. If I try right clicking on my folder name. I get an error. – ldiastx Feb 22 '16 at 15:48
  • Just try running Dude's command inside Terminal! It should loop thru all the MKV files in the current folder/directory, converting them to MP4. It preserves the names of the files, just changing the extension. – jimtut Feb 22 '16 at 17:31
  • 1
    PERFECT! Thanks so much. Works like a charm. – ldiastx Feb 23 '16 at 13:23
  • Curious what "${f%mkv}mp4" is? Learn more about "String Operations": tldp.org/LDP/abs/html/refcards.html#AEN22828 – beausmith Aug 7 '16 at 19:41

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.