#!/usr/bin/env bash # --- Configuration --- directory="_cleaned" # Use "." for current folder or set a specific path ffmpeg_options="" # Optional: Add extra flags here (usually not needed for metadata removal) # Create the target directory mkdir "$directory" echo "Starting metadata removal in: $(pwd)" # Loop through all files for file in *; do # Skip directories [ -d "$file" ] && continue # Skip the script itself [[ "$file" == "$0" ]] && continue # Skip files that already have "_clean" suffix to avoid re-processing [[ "$file" == *_clean.* ]] && continue # Construct output filename: add "_clean" before the extension base_name="${file%.*}" extension="${file##*.}" output_file="${base_name}_clean.${extension}" echo "Cleaning: $file → $output_file" # Remove metadata: -map_metadata -1 removes all metadata, -c copy avoids re-encoding if ffmpeg -loglevel quiet -i "$file" -map_metadata -1 -c copy $ffmpeg_options "$directory/$output_file"; then echo "Done: $output_file" else echo "Error: Failed to clean $file" fi done echo "All done."