47 lines
929 B
Bash
Executable file
47 lines
929 B
Bash
Executable file
#!/bin/bash
|
||
|
||
shopt -s globstar
|
||
|
||
# Initialisation de la mise en forme
|
||
blue=$(tput setaf 4)
|
||
red=$(tput setaf 1)
|
||
green=$(tput setaf 2)
|
||
reset=$(tput sgr0)
|
||
bold=$(tput bold)
|
||
|
||
# Répertoire source
|
||
rootdir="$(realpath ${1:-$PWD})"
|
||
|
||
cd "$rootdir"
|
||
|
||
# Pour tous les fichiers
|
||
for file in *
|
||
do
|
||
# S’il s’agit d’audio
|
||
if [[ "$file" =~ .mp3$ || "$file" =~ .m4a$ || "$(file --mime-type -b -e ascii -e compress -e tar -e cdf "$file")" =~ audio/ ]]
|
||
then
|
||
# Parrallélisation des traitements
|
||
declare -a running
|
||
|
||
running=($(jobs -p))
|
||
if [[ "${#running[@]}" -ge 6 ]]
|
||
then
|
||
wait -n
|
||
fi
|
||
|
||
(
|
||
# Affichage du fichier en cours de traitement
|
||
echo " $file$reset"
|
||
|
||
# Traitement
|
||
loudgain -S -r -k -q -s e "$file" &>/dev/null && \
|
||
echo "[${green} OK ${reset}] $file" || \
|
||
echo "[${red}FAIL${reset}] $file"
|
||
) &
|
||
else
|
||
# Si rien à faire, on saute.
|
||
echo "[${blue}SKIP${reset}] $file"
|
||
continue
|
||
fi
|
||
done
|
||
wait
|