#!/bin/bash
#
. /usr/local/bin/banner || exit 1
#
ext=aac
#
origem=/media
#/mp3/
#
destino=/tmp/novo_$ext/
#
cd $origem || exit 1
#
IFS=$(echo -en "\n\b")
#
clear
#
if [[ -d ${destino} ]]; then
   msg "${bama}Diretorio de Destino.: ${bbra}'${ver}$destino${bbra}'${bcia} Ja Existe${bbra}!"
   echo
else
   msg "${bama}Diretorio de Destino ${bbra}'${ver}Não Existe!${bbra}'${bama} Criando.: ${bbra}'${bcia}${destino}${bbra}'"
   echo
   mkdir -p ${destino}
fi
#
for f in *.mp2 *.mp3 *.aac *.ac3 *.m4a *.ogg *.wav; do
#
    if [[ -f "$f" ]]; then
       out=$destino${f%.*}.$ext
       #
       msg1="${bama}Convertendo o Arquivo --> ${bbra}'${bcia}${f}${bbra}'"
       msg2="${bama}Para --> ${bved}'${bbra}${out}${bved}'"
       msg $msg1 $msg2 2
       #
       msg "${bama}>>>>${ver} AGUARDE${bbra}! ${bama}<<<<" 4
       #
       ffmpeg -hide_banner -loglevel info -y -i $f -af "volume=0dB" -vn -c:a aac -ac 2 -b:a 96k -ar 44100 $out > /dev/null 2>&1
       #
       echo
# sleep 2
       tm=0
    fi
#
done
