Skip to content

Instantly share code, notes, and snippets.

@tani
Created February 9, 2015 04:55
Show Gist options
  • Save tani/3da41863cd7d5949ffcf to your computer and use it in GitHub Desktop.
Save tani/3da41863cd7d5949ffcf to your computer and use it in GitHub Desktop.
flac mp3 converter
#! /bin/bash
################################################################
# requirements: lame libav
################################################################
set -e
ROOTDIR=$1
DESTDIR=$2
function main () {
local in=${*/~/\~}
local out=${in/.flac/.mp3}
out=${out/`echo $ROOTDIR`/`echo $DESTDIR`}
mkdir -p "${out%/*}"
echo $in
avconv -y -i "$in" -acodec libmp3lame -aq 6 -map_metadata 0 "$out"
}
export -f main
find $ROOTDIR -follow -type f -print0 \
| xargs -0 -I@ -n1 -P0 bash -c "main @"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment