2021-01-22 14:46:18 +01:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
set -euo pipefail
|
|
|
|
|
2021-01-22 15:12:38 +01:00
|
|
|
# remove content of music directory
|
|
|
|
rm -rf "$HOME/Musik/"*
|
|
|
|
|
2021-01-22 14:46:18 +01:00
|
|
|
# change into music raw folder
|
2023-11-25 15:45:25 +01:00
|
|
|
cd "$HOME/Nextcloud/MusikRaw"
|
2021-01-22 14:46:18 +01:00
|
|
|
|
|
|
|
# get directories
|
2021-02-12 14:30:17 +01:00
|
|
|
ls -d */ > artistdirectories
|
|
|
|
|
|
|
|
while read -r artdir; do
|
2024-01-27 21:42:10 +01:00
|
|
|
# FIXME remove trailing slash
|
|
|
|
artdir="${artdir%/}"
|
|
|
|
# change into artist directory
|
2021-02-12 14:30:17 +01:00
|
|
|
cd "$artdir"
|
|
|
|
# get albums
|
|
|
|
ls -d */ > directories
|
|
|
|
while read -r dir; do
|
2024-01-27 21:42:10 +01:00
|
|
|
# FIXME remove trailing slash
|
|
|
|
dir="${dir%/}"
|
2021-02-12 14:30:17 +01:00
|
|
|
# change into directory
|
|
|
|
cd "$dir"
|
|
|
|
# create directory in music
|
|
|
|
mkdir -p "$HOME/Musik/${artdir}/$dir"
|
|
|
|
|
2023-11-25 16:08:44 +01:00
|
|
|
# link cover image (jpg or png)
|
|
|
|
if [ -f cover.jpg ]; then
|
|
|
|
ln -vf "$HOME/Nextcloud/MusikRaw/${artdir}/$dir/cover.jpg" "$HOME/Musik/${artdir}/$dir/"
|
|
|
|
elif [ -f cover.png ]; then
|
|
|
|
ln -vf "$HOME/Nextcloud/MusikRaw/${artdir}/$dir/cover.png" "$HOME/Musik/${artdir}/$dir/"
|
2021-02-12 14:30:17 +01:00
|
|
|
fi
|
|
|
|
|
|
|
|
# make symbolic link to music
|
|
|
|
# if the "normalized" directory exists, links are created
|
2023-11-25 16:08:44 +01:00
|
|
|
if [ -d "normalized" ]; then
|
2023-11-25 15:45:25 +01:00
|
|
|
ln -svf "$HOME/Nextcloud/MusikRaw/${artdir}/$dir/normalized/"* "$HOME/Musik/${artdir}/$dir/"
|
2021-02-12 14:30:17 +01:00
|
|
|
fi
|
|
|
|
|
|
|
|
# go back to music raw
|
2023-11-25 15:45:25 +01:00
|
|
|
cd "$HOME/Nextcloud/MusikRaw/$artdir"
|
2021-02-12 14:30:17 +01:00
|
|
|
done < directories
|
|
|
|
# cleanup
|
|
|
|
rm directories
|
2023-11-25 15:45:25 +01:00
|
|
|
cd "$HOME/Nextcloud/MusikRaw"
|
2021-02-12 14:30:17 +01:00
|
|
|
done < artistdirectories
|
|
|
|
# cleanup
|
|
|
|
rm artistdirectories
|
2021-01-22 14:46:18 +01:00
|
|
|
|
|
|
|
echo Finished!
|
|
|
|
|
|
|
|
exit
|