From 8ba0619ead0b43e0bfe380a3f04ca402d1a9f935 Mon Sep 17 00:00:00 2001 From: Claude Date: Mon, 20 Apr 2026 14:30:32 +0000 Subject: [PATCH] Fix music file matching: Mvt3 was resolving to Mvt1 for every season The old pattern *Mvt*3* matched .mp3 in every MP3 filename, so sort|head-1 always picked track 01 (Mvt1). Fix by finding all files for the season then filtering with grep -iE "Mvt[^0-9]*N[^0-9]", which requires the movement number to be surrounded by non-digit characters (space, dot, underscore) and cannot match digits embedded in .mp3 or track prefixes. https://claude.ai/code/session_01C4jbd3waXG3eKZYbGUjLUQ --- 4-seasons.sh | 3 ++- montage-mvt.sh | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/4-seasons.sh b/4-seasons.sh index 9ed36f6..ac07487 100755 --- a/4-seasons.sh +++ b/4-seasons.sh @@ -36,7 +36,8 @@ eval "$_season_info" echo "Season=$SEASON Mvt=$MVT_NUM Year=$ASTRO_YEAR Day=$DAY_OF_MVT/$DAYS_IN_MVT LastDay=$IS_LAST_DAY" # ── Locate music file and get its duration ──────────────────────────────────── -music_file=$(find "$music_base_dir" -type f -iname "*${SEASON}*Mvt*${MVT_NUM}*" | sort | head -n 1) +music_file=$(find "$music_base_dir" -type f -iname "*${SEASON}*" \ + | grep -iE "Mvt[^0-9]*${MVT_NUM}[^0-9]" | sort | head -n 1) if [ -z "$music_file" ] || [ ! -f "$music_file" ]; then echo "ERROR: Music file not found for $SEASON Mvt $MVT_NUM in $music_base_dir" exit 1 diff --git a/montage-mvt.sh b/montage-mvt.sh index 49b7d7c..9854385 100755 --- a/montage-mvt.sh +++ b/montage-mvt.sh @@ -53,7 +53,8 @@ video_dir="$MOVIES_DIR/$CAM_NAME/$ASTRO_YEAR/$SEASON/Mvt$MVT_NUM" output_dir="$video_dir/montage" mkdir -p "$output_dir" -music_file=$(find "$music_base_dir" -type f -iname "*${SEASON}*Mvt*${MVT_NUM}*" | sort | head -n 1) +music_file=$(find "$music_base_dir" -type f -iname "*${SEASON}*" \ + | grep -iE "Mvt[^0-9]*${MVT_NUM}[^0-9]" | sort | head -n 1) if [ -z "$music_file" ]; then "$SCRIPT_DIR/notify.sh" "FAILED: montage $SEASON Mvt$MVT_NUM ($ASTRO_YEAR)" \ "Music file not found in $music_base_dir" || true