#!/bin/sh # # Script de création de la liste des fichiers mp3 en HTML. VERT="33FF33" ROUGE="FF1111" today=`date '+%A %d %B %Y'` DEBUG=0 if [ "$1" = "-d" ]; then DEBUG=1 shift fi if [ "$1" = "-o" ]; then FORMAT="ogg" else FORMAT="mp3" fi TITRE=`echo "$FORMAT" | tr [a-z] [A-Z]` cat << EOF Liste des fichiers $TITRE

LISTE DES FICHIERS $TITRE


EOF tf=`ls *.$FORMAT | wc -l` echo "Nombre de fichiers à traiter : $tf" >> /dev/stderr n=0 t=0 totals=0 totalm=0 totalt=0 fond="E5E5E5" for i in *.$FORMAT; do n=`expr $n + 1` if [ $DEBUG = 1 ]; then echo "-+- DEBUG MODE ($DEBUG) -+-" >> /dev/stderr echo "Fichier : [$i], num = $n" >> /dev/stderr else echo -n "." >> /dev/stderr if [ $n = 10 -o $n = 20 -o $n = 30 -o $n = 40 ]; then echo -n " " >> /dev/stderr fi if [ $n = 50 ]; then t=`echo "$t + $n" | bc` n=0 echo " $t" >> /dev/stderr fi fi nom=`basename "$i" .mp3` if [ "$FORMAT" = "mp3" ]; then min=`mp3info -f "%m" "$i"` sec=`mp3info -f "%s" "$i"` bits=`mp3info -f "%b" "$i"` else bits=`ogginfo "$i" | grep nominal | cut -d "=" -f 2` bits=`echo "$bits / 1000" | bc` duree=`ogginfo "$i" | grep playtime | cut -d "=" -f 2` min=`echo "$duree" | cut -d ":" -f 1` sec=`echo "$duree" | cut -d ":" -f 2` fi if [ $bits -gt 128 ]; then couleur="" fincouleur="" elif [ $bits -lt 128 ]; then couleur="" fincouleur="" else couleur="" fincouleur="" fi totals=`echo "$totals + $sec" | bc` totalm=`echo "$totalm + $min" | bc` if [ $min -lt 10 ]; then min="0$min" fi if [ $sec -lt 10 ]; then sec="0$sec" fi taille=`ls -lh "$i" | awk '{print $5}' | sed -e 's/M//'` point=`echo $taille | grep "\."` if [ "$point" = "" ]; then taille="$taille.0" fi totalt=`echo "$totalt + $taille" | bc` if [ "$fond" = "E5E5E5" ]; then fond="EBEBEB" else fond="E5E5E5" fi echo " " echo " " echo " " echo " " echo " " echo " " done echo "" >> /dev/stderr mis=`echo "$totals / 60" | bc` totals=`echo "$totals - $mis * 60" | bc` totalm=`echo "$totalm + $mis " | bc` totalh=`echo "$totalm / 60" | bc` totalm=`echo "$totalm - $totalh * 60" | bc` if [ $totalm -lt 10 ]; then totalm="0$totalm" fi if [ $totals -lt 10 ]; then totals="0$totals" fi echo "Durée totale = $totalh:$totalm:$totals" >> /dev/stderr echo "Taille totale = $totalt Mo" >> /dev/stderr cat << EOF
ARTISTE - TITRE
DURÉE
BITS
TAILLE
$nom
$min:$sec
$couleur$bits$fincouleur
$taille Mo
 
TOTAL
$totalh:$totalm:$totals
 
$totalt Mo
Mis à jour le $today
EOF