All pastes #165587 Raw Edit

profoX

public text v1 · immutable
·published 2006-09-10 00:11 UTC
rendered paste body
#!/bin/bash

# simple mp3gain nautilus script
# for normalizing mp3 files
#
#    written by Wesley S. (profox@ubuntu-nl.org)
#
# released under GPLv2
# feel free to use in any way

no_mp3s=""
could_not_open=""
no_change=""

(
        for file in "$@"; do
                extension=`echo ${file##*.} | tr A-Z a-z`
                if [ $extension = "mp3" ]; then
                        outfile=`mp3gain -r -c $file`
                        echo $outfile|grep "Can't open"
                        if [ $? = 0 ]; then
                                could_not_open="$could_not_open\n$file"
                                echo "Could not open: $file"
                        fi
                        echo $outfile|grep "No changes to"
                        if [ $? = 0 ]; then
                                no_change="$no_change\n$file"
                                echo "no changez: $file"
                        fi
                else
                        no_mp3s="$no_mp3s\n$file"
                fi
        done
) | zenity --progress --auto-close --title "Normalizing MP3 files" --text "Normalizing file $file" --pulsate
if [ $no_mp3s = "" ]; then
        warning=""
else
        warning="\n\nWarning:\n\nThe following files were not detected as mp3 files:\n$no_mp3s"
fi
if [ $no_change != "" ]; then
        warning="$warning\n\nThe following files didn't need normalization:\n$no_change"
fi

zenity --info --title "Normalizing completed" --text "Normalizing completed.$warning"