#!/bin/bash shopt -s globstar if (($# < 1)); then echo "usage: ${0##*/} " exit fi if [[ ! -d $1 ]]; then echo "argument must be a directory" exit 1 fi dir=${1%/} copydir_suffix="_mp3" find "$dir" -type d -exec echo mkdir -p ${dir}${copydir_suffix}/{} + find "$dir" -type f -name '*.flac' -print0 | parallel -0 echo ffmpeg -i {} -qscale:a 0 '{=s#^([^/])(.*)\.flac$#\1'"${copydir_suffix}"'\2.mp3#=}'