-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmove_to_mp3.sh
37 lines (31 loc) · 934 Bytes
/
move_to_mp3.sh
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
origin_folder="/mnt/afaces_albums"
destination_folder="${HOME}/afaces.github.io/assets/music"
#test -f "${i%.wav}.mp3" || lame -b 320 -h "${i}" "${i%.wav}.mp3"
mkdir -p "${destination_folder}"
if ! which lame; then
if [ "${EUID}" -eq 0 ]; then
apt-get install -y lame
else
sudo apt-get install -y lame
fi
fi
if [ ! -d "${origin_folder}" ]; then
echo "The music folder is not found"
exit 1
fi
current_directory="$(pwd)"
cd "${origin_folder}"
for album in *; do
cd "${album}"
echo "Enter in album ${album}"
mkdir -p "${destination_folder}/${album}"
for song in *; do
#test -f "${song%.wav}.mp3" || lame -b 320 -h "${song}" "${song%.wav}.mp3"
if echo "${song}" | grep -Eq '.*.wav'; then
echo "Converting song ${song} to mp3 and moving to repository folder"
lame -b 320 -h "${song}" "${destination_folder}/${album}/${song%.wav}.mp3"
fi
done
cd ..
done
cd "${current_directory}"