dotfiles/.local/bin/music-replaygain-solo

48 lines
929 B
Text
Raw Normal View History

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
# Sil sagit daudio
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))
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