-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmp3normalize.sh
More file actions
executable file
·50 lines (40 loc) · 886 Bytes
/
mp3normalize.sh
File metadata and controls
executable file
·50 lines (40 loc) · 886 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#!/bin/bash
OLDIFS=$IFS;
IFS=$'\n';
MP3DIR=("$HOME/Musik/" "$HOME/Downloads/MP3's");
GAIN=$(which replaygain);
LOGFILE="gain.log";
# check if mp3gain is installed
if [ -z "$GAIN" ]; then
echo "replaygain not installed";
exit 1;
fi
# delete existing logfile
if [ -e "$LOGFILE" ]; then
rm -f $LOGFILE;
fi
# create an empty logfile
touch $LOGFILE;
# process directories array
for DIR in "${MP3DIR[@]}"; do
# make sure the directory exists
if [ ! -d "$DIR" ]; then
continue
fi
echo "$DIR";
# create filelist for current directory
if [ -z "$1" ]; then
FILES=$(find "$DIR" -name '*mp3'|sort);
else
FILES=$(find "$DIR/$1" -name '*mp3'|sort);
fi
# gain files in current directory
for MP3 in $FILES; do
"$GAIN" "$MP3"
done;
done;
# show log only if --show-log is passed as parameter
if [ "$1" == "--show-log" ]; then
cat gain.log;
fi
IFS=$OLDIFS