2021-12-11 21:37:40 +01:00
|
|
|
|
#!/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
|
2022-01-10 19:37:13 +01:00
|
|
|
|
if [[ "$file" =~ .mp3$ || "$file" =~ .m4a$ || "$(file --mime-type -b -e ascii -e compress -e tar -e cdf "$file")" =~ audio/ ]]
|
2021-12-11 21:37:40 +01:00
|
|
|
|
then
|
|
|
|
|
# Parrallélisation des traitements
|
|
|
|
|
declare -a running
|
|
|
|
|
|
|
|
|
|
running=($(jobs -p))
|
2022-05-18 23:22:55 +02:00
|
|
|
|
if [[ "${#running[@]}" -ge 6 ]]
|
2021-12-11 21:37:40 +01:00
|
|
|
|
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
|