Script pour le replaygain de masse
This commit is contained in:
parent
3ff0a185f6
commit
9cfcb89e06
2 changed files with 122 additions and 0 deletions
72
.local/bin/music-replaygain
Executable file
72
.local/bin/music-replaygain
Executable file
|
@ -0,0 +1,72 @@
|
|||
#!/bin/bash
|
||||
|
||||
# Sortie à la moindre erreur
|
||||
set -e
|
||||
|
||||
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:-${HOME}/Musique/})"
|
||||
|
||||
cd "$rootdir"
|
||||
|
||||
# Pour tous les sous-répertoires, à tous les niveaux
|
||||
for dir in **/ .
|
||||
do
|
||||
# On entre dans le répertoire à traiter
|
||||
cd "${rootdir}/${dir}"
|
||||
|
||||
# Liste des fichiers à traiter
|
||||
unset todo
|
||||
declare -a todo
|
||||
|
||||
# Pour chaque fichier
|
||||
for file in *
|
||||
do
|
||||
# On ignore les dossiers
|
||||
if [[ -d "${file}" ]]
|
||||
then
|
||||
continue
|
||||
fi
|
||||
|
||||
# S’il s’agit d’audio
|
||||
if [[ "$(file --mime-type -b -e ascii -e compress -e tar -e cdf "$file")" =~ audio/ ]]
|
||||
then
|
||||
todo+=("$file")
|
||||
fi
|
||||
done
|
||||
|
||||
# Si rien à faire, on saute.
|
||||
if [[ "${#todo}" -eq 0 ]]
|
||||
then
|
||||
echo "[${blue}SKIP${reset}] $dir"
|
||||
continue
|
||||
fi
|
||||
|
||||
# Parrallélisation des traitements
|
||||
declare -a running
|
||||
|
||||
running=($(jobs -p))
|
||||
if [[ "${#running[@]}" -ge 12 ]]
|
||||
then
|
||||
wait -n
|
||||
fi
|
||||
|
||||
(
|
||||
# Affichage du répertoire en cours de traitement
|
||||
echo " $dir$reset"
|
||||
|
||||
# Traitement
|
||||
loudgain -S -a -k -q -s e "${todo[@]}" &>/dev/null && \
|
||||
echo "[${green} OK ${reset}] $dir" || \
|
||||
echo "[${red}FAIL${reset}] $dir"
|
||||
) &
|
||||
done
|
||||
wait
|
50
.local/bin/music-replaygain-solo
Executable file
50
.local/bin/music-replaygain-solo
Executable file
|
@ -0,0 +1,50 @@
|
|||
#!/bin/bash
|
||||
|
||||
# Sortie à la moindre erreur
|
||||
set -e
|
||||
|
||||
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 --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 12 ]]
|
||||
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
|
Loading…
Reference in a new issue