set -e dir="$1" ext="$2" find "${dir}" -type f | while read file; do if [[ $file =~ .${ext} ]]; then output="${file%.${ext}}.mp3" ffmpeg -n -i "${file}" -b:a 320k "${output}" fi done