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

47 lines
929 B
Bash
Executable file
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/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
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