#!/bin/bash
#
ext=mp3
#
origem=/mp3/
#
destino=/tmp/novo_$ext/
#
# Regular Colors
Black='\e[0;30m'  # Black
Red='\e[0;31m'    # Red
Green='\e[0;32m'  # Green
Yellow='\e[0;33m' # Yellow
Blue='\e[0;34m'   # Blue
Purple='\e[0;35m' # Purple
Cyan='\e[0;36m'   # Cyan
White='\e[0;37m'  # White
# Bold
BBlack='\e[1;30m'  # Black
BRed='\e[1;31m'    # Red
BGreen='\e[1;32m'  # Green
BYellow='\e[1;33m' # Yellow
BBlue='\e[1;34m'   # Blue
BPurple='\e[1;35m' # Purple
BCyan='\e[1;36m'   # Cyan
BWhite='\e[1;37m'  # White
#
if [[ -d ${destino} ]]; then
    echo -e "Diretorio$BGreen ja Existe!$BWhite"
else
    echo -e "Diretorio$BRed Não Existe!$BWhite Criando.: $BGreen$destino"
    mkdir $destino
fi
#
cd $origem
#
IFS=$(echo -en "\n\b")
#
lista=(
'mp3'
'aac'
'ac3'
'm4a'
'ogg'
'mp2'
'wav'
)
for f in *."${lista[@]}"; do
    tx1=`echo $f | cut -d '.' -f1 `
    out=$destino$tx1.$ext
    #
    echo "###############################################################################################"
    echo -e "\e[1;32mConvertendo o Arquivo --> $f\e[0m"
    echo -e "\e[1;33mPara --> $out\e[0m"
    echo "###############################################################################################"
    #
    sleep 1
    #
#    ffmpeg -loglevel info -i $f -af "volume=0dB" -c:a libmp3lame -ac 2 -b:a 128k -ar 44100 $out
echo "ffmpeg -loglevel info -i $f -af "volume=0dB" -c:a libmp3lame -ac 2 -b:a 128k -ar 44100 $out"
    #
done
