From c2b54077a99bdd6f1829cc847bf74b2b854fce30 Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 21 Apr 2026 11:11:15 +0000 Subject: [PATCH] Add --cam/--season/--mvt filters to make-finals.sh Allows processing a single movement without waiting for the full backup scan, e.g.: ./make-finals.sh ~/drives/data2-main --cam north --season Autumn --mvt 1 Filters are applied as soon as the relevant variable is known (cam before calling season_info.py, season/mvt after) so skipped files cost almost nothing. https://claude.ai/code/session_01C4jbd3waXG3eKZYbGUjLUQ --- make-finals.sh | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/make-finals.sh b/make-finals.sh index 23e6432..9ede6a4 100755 --- a/make-finals.sh +++ b/make-finals.sh @@ -24,18 +24,24 @@ export TIMEZONE BACKUP_ROOT="" DRY_RUN=false +FILTER_CAM="" +FILTER_SEASON="" +FILTER_MVT="" while [[ $# -gt 0 ]]; do case "$1" in - --dry-run) DRY_RUN=true; shift ;; - -*) echo "Unknown option: $1"; exit 1 ;; - *) BACKUP_ROOT="$1"; shift ;; + --dry-run) DRY_RUN=true; shift ;; + --cam) FILTER_CAM="$2"; shift 2 ;; + --season) FILTER_SEASON="$2"; shift 2 ;; + --mvt) FILTER_MVT="$2"; shift 2 ;; + -*) echo "Unknown option: $1"; exit 1 ;; + *) BACKUP_ROOT="$1"; shift ;; esac done if [ -z "$BACKUP_ROOT" ]; then - echo "Usage: $0 [--dry-run]" - echo " e.g. $0 ~/drives/data2-main --dry-run" + echo "Usage: $0 [--cam CAM] [--season SEASON] [--mvt N] [--dry-run]" + echo " e.g. $0 ~/drives/data2-main --cam north --season Autumn --mvt 1" exit 1 fi @@ -46,6 +52,9 @@ music_base_dir="$MUSIC_DIR" $DRY_RUN && echo "DRY RUN — no files will be written" echo "Scanning: $BACKUP_ROOT" echo "Output: $MOVIES_DIR" +[ -n "$FILTER_CAM" ] && echo "Filter: cam=$FILTER_CAM" +[ -n "$FILTER_SEASON" ] && echo "Filter: season=$FILTER_SEASON" +[ -n "$FILTER_MVT" ] && echo "Filter: mvt=$FILTER_MVT" echo "" # Known camera names in order of specificity (longer matches first) @@ -80,6 +89,7 @@ while IFS= read -r -d '' temp_file; do (( skipped++ )) || true continue fi + [ -n "$FILTER_CAM" ] && [ "$cam" != "$FILTER_CAM" ] && continue _info="$(python3 "$SCRIPT_DIR/season_info.py" "$date_str" 2>/dev/null)" || { echo "SKIP (season_info failed $date_str): $filename" @@ -87,6 +97,8 @@ while IFS= read -r -d '' temp_file; do continue } eval "$_info" + [ -n "$FILTER_SEASON" ] && [ "$SEASON" != "$FILTER_SEASON" ] && continue + [ -n "$FILTER_MVT" ] && [ "$MVT_NUM" != "$FILTER_MVT" ] && continue music_file=$(find "$music_base_dir" -type f -iname "*${SEASON}*" \ | grep -iE "Mvt[^0-9]*${MVT_NUM}[^0-9]" | sort | head -n 1)