#!/bin/bash notify() { notify-send "Spotdl Sync" "$1" --icon=spotify --app-name=spotify } if ! command -v spotdl &>/dev/null; then notify "Error: spotdl is not installed" exit 1 fi MUSIC_FOLDER="$HOME/Musica/Listen-To" notify "Started syncing..." while IFS= read -r -d '' FOLDER; do FOLDER_NAME=$(basename "$FOLDER") SPOTDL_FILE=$(find "$FOLDER" -maxdepth 1 -type f -name '*.spotdl' -print -quit) if [ -n "$SPOTDL_FILE" ]; then cd "$(dirname "$SPOTDL_FILE")" || continue spotdl sync "$(basename "$SPOTDL_FILE")" notify "Synced $FOLDER_NAME" fi done < <(find "$MUSIC_FOLDER" -mindepth 1 -maxdepth 1 -type d -print0) notify "Spotdl Sync Complete"