#!/bin/bash
#
ext=mp3
#
origem=/media/
#
destino=/tmp/novo_$ext/
#
source ./cores
#
cd $origem
#
IFS=$(echo -en "\n\b")
#
clear
#
if [[ -d ${destino} ]]; then
   msg=$cbama"Diretorio de Destino.: $cbver${destino} $cbbra'${cbcia}Ja Existe$cbbra!' "$cfim
   tmh=43
   msg $msg $tmh
   echo
else
   msg=$cbama"Diretorio de Destino$cver Não Existe!$cbbra Criando.: $cbcia${destino}"$cfim
   tmh=27
   msg $msg $tmh
   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="Convertendo o Arquivo --> $bbranco'$f'"
       tmh1=6
       msg2="Para --> $bbranco$out"
       tmh2=6
       msg $msg1 $tmh1 $msg2 $tmh2
       #
       msg3="$ver<<<< AGUARDE >>>>"
       tmh3=6
       msg $msg3 $tmh3 1
       #
       ffmpeg -hide_banner -loglevel info -y -i $f -af "volume=0dB" -c:a libmp3lame -ac 2 -b:a 128k -ar 44100 $out # > /dev/null 2>&1
       #
       echo
    fi
#
done
