diff --git a/migrate-seasons.sh b/migrate-seasons.sh index f1c3640..8328498 100755 --- a/migrate-seasons.sh +++ b/migrate-seasons.sh @@ -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" with no -# preceding digit, e.g. 2026-03-21_Mvt3-Dayof92-final.mp4) -# → moved to the correct $MOVIES_DIR//2025//Mvt/ -# -# QUARANTINE — clips produced by the later broken script that recorded a -# specific day number but used the wrong movement total -# (filename has Dayof92, e.g. 2026-04-10_Mvt1-Day21of92-final.mp4) -# → moved to $MOVIES_DIR//2025/quarantine-old-scripts/ -# Review and delete when you're done: rm -rf -# # 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: Dayof92 -# (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"