-
Notifications
You must be signed in to change notification settings - Fork 29
Expand file tree
/
Copy pathmp32wav.sh
More file actions
executable file
·41 lines (35 loc) · 835 Bytes
/
mp32wav.sh
File metadata and controls
executable file
·41 lines (35 loc) · 835 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
#!/bin/bash
# @author Fred Brooker <git@gscloud.cz>
if [ $# -eq 0 ]; then
echo -e "\nConvert MP3 files to WAV recursively.\n\nSyntax: $(basename $0) <folder>\n"
exit 1
fi
which ffmpeg >/dev/null 2>&1 || (echo "Installing ffmpeg" && sudo apt-get install -yqq ffmpeg)
which ffmpeg >/dev/null 2>&1 || (echo "ERROR: ffmpeg is not installed" && exit 1)
if [ -n "$1" ]; then
if [ -d "$1" ]; then
cd "$1"
else
echo "Invalid folder: $1"
exit 1
fi
fi
for i in *; do
if [ -d "$i" ]; then
echo "Recursing into directory: $i"
$0 "$i"
fi
done
for i in *.mp3; do
if [ -f "$i" ]; then
echo "Converting: $i"
ffmpeg -i "$i" "${i%.mp3}.wav"
if [ $? -eq 0 ]; then
echo "Successfully converted: $i"
rm -f "$i"
else
echo "Failed to convert: $i"
fi
fi
done
echo -e "Done.\n"