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
This commit is contained in:
Claude
2026-04-20 14:30:32 +00:00
parent 331bce38c4
commit 8ba0619ead
2 changed files with 4 additions and 2 deletions
+2 -1
View File
@@ -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
+2 -1
View File
@@ -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