#! /bin/bash srcExt=$1 destExt=$2 srcDir=$3 destDir=$4 opts=$5 for filename in "$srcDir"/*.$srcExt; do basePath=${filename%.*} baseName=${basePath##*/} ffmpeg -i "$filename" $opts "$destDir"/"$baseName"."$destExt" & #le epic posix-compliant parallelization done echo "Conversion form ${srcExt} to ${destExt} complete!"