Simplify migrate-seasons.sh: migrate all clips, drop quarantine logic

All *-final.mp4 clips are valid footage regardless of what speed factor
the old script used — montage-mvt.sh re-adjusts the full concatenated
video to match music duration anyway, so per-clip speed is irrelevant.

Move every ASTRO_YEAR=2025 clip to the correct new movement directory
based on its date. Spring Mvt1 now gets all 30 clips (Mar 21–Apr 19).

https://claude.ai/code/session_01C4jbd3waXG3eKZYbGUjLUQ
This commit is contained in:
Claude
2026-04-20 14:16:13 +00:00
parent 7affbc5c54
commit 331bce38c4
+35 -70
View File
@@ -2,19 +2,13 @@
# migrate-seasons.sh — move old-format seasons clips into the new sky-cam
# directory structure for astronomical year 2025 only (Winter 2025-26 onward).
#
# Every *-final.mp4 clip is placed in the correct movement directory based on
# its YYYY-MM-DD filename date, regardless of how the old script labelled it.
# montage-mvt.sh re-adjusts speed for the whole movement anyway, so per-clip
# speed accuracy doesn't matter.
#
# Earlier years (Autumn 2025 / ASTRO_YEAR=2024 and before) are skipped.
#
# Two categories of old file:
# MIGRATE — clips from the legacy script (filename has "Dayof<N>" with no
# preceding digit, e.g. 2026-03-21_Mvt3-Dayof92-final.mp4)
# → moved to the correct $MOVIES_DIR/<cam>/2025/<Season>/Mvt<N>/
#
# QUARANTINE — clips produced by the later broken script that recorded a
# specific day number but used the wrong movement total
# (filename has Day<digit>of92, e.g. 2026-04-10_Mvt1-Day21of92-final.mp4)
# → moved to $MOVIES_DIR/<cam>/2025/quarantine-old-scripts/
# Review and delete when you're done: rm -rf <quarantine dir>
#
# Usage:
# ./migrate-seasons.sh [--dry-run] [OLD_ROOT]
#
@@ -23,7 +17,7 @@
# (default: ~/drives/local-2tb/movies/sunrise)
#
# After running, trigger montages for completed movements:
# ./montage-mvt.sh 2026-04-19 east # Spring Mvt1 (~20/31 days)
# ./montage-mvt.sh 2026-04-19 east # Spring Mvt1 (~30/31 days)
# ./montage-mvt.sh 2026-01-18 east # Winter Mvt1 (~18/29 days)
# ./montage-mvt.sh 2026-02-16 east # Winter Mvt2 (~24/29 days)
# ./montage-mvt.sh 2026-03-19 east # Winter Mvt3 (~20/31 days)
@@ -45,44 +39,14 @@ done
CAM="$SUNRISE_CAM"
NEW_ROOT="$MOVIES_DIR/$CAM/2025"
QUARANTINE="$NEW_ROOT/quarantine-old-scripts"
echo "Old archive : $OLD_ROOT"
echo "New root : $NEW_ROOT"
echo "Quarantine : $QUARANTINE"
echo "Camera : $CAM"
echo "Old archive : $OLD_ROOT"
echo "New root : $NEW_ROOT"
echo "Camera : $CAM"
$DRY_RUN && echo "(DRY RUN — no files will be moved)"
echo ""
declare -A CNT_MIGRATE CNT_QUARANTINE CNT_SKIP
do_move() {
local src="$1" dst="$2" label="$3" key="$4"
local dst_dir
dst_dir="$(dirname "$dst")"
if [ -e "$dst" ]; then
printf " EXISTS %-11s %s\n" "" "$(basename "$src")"
CNT_SKIP["$key"]=$(( ${CNT_SKIP["$key"]:-0} + 1 ))
return
fi
if $DRY_RUN; then
printf " %-10s %s\n %13s-> %s/\n" \
"$label" "$(basename "$src")" "" "$dst_dir"
else
mkdir -p "$dst_dir"
mv "$src" "$dst"
fi
case "$label" in
MIGRATE) CNT_MIGRATE["$key"]=$(( ${CNT_MIGRATE["$key"]:-0} + 1 )) ;;
QUARANTINE) CNT_QUARANTINE["$key"]=$(( ${CNT_QUARANTINE["$key"]:-0} + 1 )) ;;
esac
}
# Returns true if filename has the bad pattern: Day<digit(s)>of92
# (specific day number + wrong 92-day total from the broken Spring script)
is_quarantine_candidate() {
[[ "$1" =~ Day[0-9]+of92 ]]
}
declare -A CNT_MOVED CNT_SKIP
while IFS= read -r -d '' src; do
fname="$(basename "$src")"
@@ -102,19 +66,29 @@ while IFS= read -r -d '' src; do
eval "$info"
# Provides: SEASON MVT_NUM DAY_OF_MVT DAYS_IN_MVT ASTRO_YEAR ...
# Skip everything outside the current astronomical year
# Only process the current astronomical year
if [ "$ASTRO_YEAR" != "2025" ]; then
continue
fi
key="${SEASON}/Mvt${MVT_NUM}"
dst="$NEW_ROOT/$SEASON/Mvt$MVT_NUM/$fname"
if is_quarantine_candidate "$fname"; then
do_move "$src" "$QUARANTINE/$fname" "QUARANTINE" "$key"
else
do_move "$src" "$NEW_ROOT/$SEASON/Mvt$MVT_NUM/$fname" "MIGRATE" "$key"
if [ -e "$dst" ]; then
printf " EXISTS %s\n" "$fname"
CNT_SKIP["$key"]=$(( ${CNT_SKIP["$key"]:-0} + 1 ))
continue
fi
if $DRY_RUN; then
printf " Day %2s/%-2s %s -> %s/Mvt%s/\n" \
"$DAY_OF_MVT" "$DAYS_IN_MVT" "$fname" "$SEASON" "$MVT_NUM"
else
mkdir -p "$(dirname "$dst")"
mv "$src" "$dst"
fi
CNT_MOVED["$key"]=$(( ${CNT_MOVED["$key"]:-0} + 1 ))
done < <(find \
"$OLD_ROOT/Spring" \
"$OLD_ROOT/Winter" \
@@ -123,30 +97,23 @@ done < <(find \
echo ""
echo "=== Summary (ASTRO_YEAR=2025 only) ==="
printf "%-22s %8s %11s %7s\n" "Movement" "Migrated" "Quarantined" "Skipped"
printf "%-22s %8s %11s %7s\n" "--------" "--------" "-----------" "-------"
printf "%-22s %6s %7s\n" "Movement" "Moved" "Skipped"
printf "%-22s %6s %7s\n" "--------" "-----" "-------"
declare -A ALL_KEYS
for k in "${!CNT_MIGRATE[@]}" "${!CNT_QUARANTINE[@]}" "${!CNT_SKIP[@]}"; do
ALL_KEYS["$k"]=1
done
for k in "${!CNT_MOVED[@]}" "${!CNT_SKIP[@]}"; do ALL_KEYS["$k"]=1; done
total_m=0 total_q=0
total=0
for key in $(printf '%s\n' "${!ALL_KEYS[@]}" | sort); do
m=${CNT_MIGRATE["$key"]:-0}
q=${CNT_QUARANTINE["$key"]:-0}
m=${CNT_MOVED["$key"]:-0}
s=${CNT_SKIP["$key"]:-0}
printf "%-22s %8d %11d %7d\n" "$key" "$m" "$q" "$s"
total_m=$(( total_m + m ))
total_q=$(( total_q + q ))
printf "%-22s %6d %7d\n" "$key" "$m" "$s"
total=$(( total + m ))
done
printf "%-22s %8d %11d\n" "TOTAL" "$total_m" "$total_q"
printf "%-22s %6d\n" "TOTAL" "$total"
echo ""
if $DRY_RUN; then
echo "Re-run without --dry-run to move the files."
echo ""
fi
$DRY_RUN && echo "Re-run without --dry-run to move the files." && echo ""
echo "Next steps:"
echo " 1. Build montages for completed movements:"
@@ -156,6 +123,4 @@ echo " ./montage-mvt.sh 2026-02-16 $CAM # Winter Mvt2"
echo " ./montage-mvt.sh 2026-03-19 $CAM # Winter Mvt3"
echo " 2. Confirm each montage plays correctly with music."
echo " 3. Delete temp files from old archive:"
echo " find $OLD_ROOT -name '*-temp.mp4' -delete"
echo " 4. Delete quarantined bad clips once confirmed:"
echo " rm -rf $QUARANTINE"
echo " find \"$OLD_ROOT\" -name '*-temp.mp4' -delete"