Skip to content

Instantly share code, notes, and snippets.

@dmytro
Last active August 29, 2015 14:05
Show Gist options
  • Save dmytro/8e849df63949e91d8f19 to your computer and use it in GitHub Desktop.
Save dmytro/8e849df63949e91d8f19 to your computer and use it in GitHub Desktop.
Shell script to convert FLAC or APE files to MP3
#!/bin/bash
doit () {
NAME="$*"
echo $NAME
NAME=$(echo $NAME | sed 's;^\.\/;;')
DIR=$(dirname "$NAME")
FILE="$(echo $(basename ${NAME}) | sed 's/\.[^\.]*$//')"
OUT=tmp/$DIR
OFILE="${OUT}/${FILE}.mp3"
mkdir -p "$OUT"
if test -f "${OFILE}" ; then
echo "============================================ $OFILE already exists"
else
ffmpeg -loglevel panic -i "$NAME" -f mp3 -ab 192000 "${OFILE}" || true
echo "============================================ DONE ${FILE} "
ls -l "$OFILE"
fi
return 0
}
export -f doit
/usr/bin/find -E . -regex ".*(ape|flac)" -exec bash -c 'doit "{}"' \;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment