04-20-2025, 08:08 AM
Hi @Tim Curtis,
The final working solution is:
1) Exclude the playlists from the backup. This is optional
2) Run the script I made.
The script removes everything ( when "all" as argument) and creates symlinks to the playlists and playlist covers on the NAS, or just replaces local files with symlinks to the NAS content
The final working solution is:
1) Exclude the playlists from the backup. This is optional
2) Run the script I made.
The script removes everything ( when "all" as argument) and creates symlinks to the playlists and playlist covers on the NAS, or just replaces local files with symlinks to the NAS content
Code:
#!/bin/bash
DESTINATION_FOLDER_PLAYLISTS=/var/lib/mpd/playlists
DESTINATION_FOLDER_PLAYLIST_COVERS=/var/local/www/imagesw/playlist-covers
# all as argument removes everything
if [[ "$1" == "all" ]]
then
echo "Removing all playlists and playlist covers"
sudo rm $DESTINATION_FOLDER_PLAYLISTS/*.m3u 2>/dev/null
sudo rm $DESTINATION_FOLDER_PLAYLIST_COVERS/*.jpg 2>/dev/null
fi
# Playlists
echo "Patch playlists"
SOURCE_FOLDER=/mnt/NAS/Music/Playlists/*.m3u
for filepath in $SOURCE_FOLDER; do
file=$(basename -- "$filepath")
symlink_file="$DESTINATION_FOLDER_PLAYLISTS/$file"
sudo rm "$symlink_file" 2>/dev/null
sudo ln -s "$filepath" "$symlink_file"
done
# Playlist covers
echo "Patch playlist covers"
SOURCE_FOLDER=/mnt/NAS/Music/Playlists/*.jpg
for filepath in $SOURCE_FOLDER; do
file=$(basename -- "$filepath")
symlink_file="$DESTINATION_FOLDER_PLAYLIST_COVERS/$file"
sudo rm "$symlink_file" 2>/dev/null
sudo ln -s "$filepath" "$symlink_file"
done