Programming
ffmpeg batch-processing os-agnostic
Updated Wed, 03 Aug 2022 11:59:14 GMT

How do you convert an entire directory with ffmpeg?


How do you convert an entire directory/folder with ffmpeg via command line or with a batch script?




Solution

Previous answer will only create 1 output file called out.mov. To make a separate output file for each old movie, try this.

for i in *.avi;
  do name=`echo "$i" | cut -d'.' -f1`
  echo "$name"
  ffmpeg -i "$i" "${name}.mov"
done




Comments (5)

  • +0 – If you're like me and have lots of spaces (and a few other problematic characters) in your file names, I'd suggest addding double quotes : ffmpeg -i "$i" "$name.mov"; — Dec 17, 2012 at 22:36  
  • +9 – I'm getting the error i was unexpected at this time. — May 17, 2014 at 01:09  
  • +8do name=`echo "${i%.*}"`; will work on file names with dots (and spaces) in them. — Jun 30, 2015 at 14:50  
  • +3 – is this support for .bat in windows? — Jun 30, 2018 at 06:12  
  • +3 – @Jazuly No, this is sh syntax. You can install Bash on Windows if you aren't yet prepared to ditch Windows entirely. — Jun 25, 2019 at 16:07