#!/bin/bash # Find all directories two levels deep (Artist/Album) containing FLAC files find . -type f -iname "*.flac" | \ awk -F/ 'NF>=3 {print $(NF-2) "/" $(NF-1)}' | sort -u | while read -r album_path; do full_album_path="./$album_path" echo "Processing album: $full_album_path" # Run metaflac on all FLAC files in the album directory metaflac --add-replay-gain "$full_album_path"/*.flac done