#!/usr/bin/env bash DEFAULT_BASEDIR=$(pwd) DEFAULT_CONVERTER="ffmpeg" FLACDIR="flac" MP3DIR="mp3" while [[ $# -gt 0 ]]; do opt="$1" shift; case "$opt" in "-d"|"--dir") BASEDIR="$1" shift; ;; "-c"|"--converter") CONVERTER="$1" shift; ;; "-h"|"--help") usage ;; esac done if [ -z ${BASEDIR} ]; then echo "No Basedir parameter given." BASEDIR="${DEFAULT_BASEDIR}" fi if [ -z ${CONVERTER} ]; then CONVERTER="${DEFAULT_CONVERTER}" fi usage() { cat< $(basename $DSTPATH)" if [ ${CONVERTER} == "libav" ]; then # Convert using libav avconv -i "${SRCPATH}" -c:a libmp3lame -b:a 192k -map_metadata 0:g:0 "${DSTPATH}" elif [ ${CONVERTER} == "ffmpeg" ]; then # Convert using ffmpeg ffmpeg -i "${SRCPATH}" -ab 192k -vcodec copy -map_metadata 0:g:0 -hide_banner -v 0 "${DSTPATH}" fi fi let CURRENT-=1 done } echo "Using ${BASEDIR} as basedir" echo " Therefore we are converting from ${BASEDIR}/${FLACDIR} to ${BASEDIR}/${MP3DIR}" read -p "Press any key to continue... (CTRL+C to abort)" -n1 -s cd ${BASEDIR} convert_to_mp3 # vim: set ts=2 sw=2 tw=0 noet :