#!/usr/bin/env bash # Download DOP20 assets (JP2/J2W/XML) listed line-by-line in archive/dop20/filelist.txt. set -euo pipefail ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")"/.. && pwd)" DOP_ROOT="$ROOT/raw/dop20" LIST="${LIST:-$ROOT/archive/dop20/filelist.txt}" OUT_JP2="$DOP_ROOT/jp2" OUT_J2W="$DOP_ROOT/j2w" OUT_META="$DOP_ROOT/meta" if [[ ! -f "$LIST" ]]; then echo "Missing filelist: $LIST" >&2 exit 1 fi mkdir -p "$OUT_JP2" "$OUT_J2W" "$OUT_META" while IFS= read -r url; do [[ -z "$url" || "$url" =~ ^# ]] && continue fname="${url##*/}" case "$fname" in *.jp2) dest="$OUT_JP2/$fname" ;; *.j2w) dest="$OUT_J2W/$fname" ;; *_meta.xml) dest="$OUT_META/$fname" ;; *) echo "Skipping unknown asset type: $fname" >&2; continue ;; esac if [[ -f "$dest" ]]; then echo "Exists: $fname" continue fi echo "Downloading $fname" curl -fL "$url" -o "$dest" done < "$LIST" echo "Done. Files in $OUT_JP2, $OUT_J2W, $OUT_META"