#!/bin/bash

# Use find to safely handle filenames with spaces and special characters
find . -maxdepth 1 -type f -name "*.mp3" | while IFS= read -r file; do
    # Extract filename without ./ prefix
    basefile="${file#./}"

    # Remove bracketed content
    new_name=$(echo "$basefile" | sed -E 's/\s*\[[^]]*\]//g')

    # Rename the file only if the new name is different
    if [[ "$basefile" != "$new_name" ]]; then
        mv -- "$basefile" "$new_name"
        echo "Renamed: '$basefile' → '$new_name'"
    fi
done
