#!/usr/bin/env bash set -euo pipefail EXTENSIONS="cue|m3u|m3u8|pls|wpl|xspf|nfo|txt|log|accurip|sfv|md5" TARGET="${1:-${INPUT_FILE_PATH:-}}" if [[ -z "$TARGET" ]]; then echo "Error: No directory path provided" >&2 exit 1 fi if [[ ! -d "$TARGET" ]]; then echo "Error: Not a directory: $TARGET" >&2 exit 1 fi deleted=0 while IFS= read -r -d '' file; do echo "Deleting: $file" rm "$file" deleted=$((deleted + 1)) done < <(find "$TARGET" -type f -regextype posix-extended -iregex ".*\.($EXTENSIONS)" -print0 | sort -z) if [[ $deleted -eq 0 ]]; then echo "No playlist/cue files found in: $TARGET" else echo "" echo "Summary: $deleted files deleted" fi