#!/bin/zsh SRC_ROOT="tiles_italy_new" DST_ROOT="merged_tiles" mkdir -p "$DST_ROOT" echo "[INFO] Merge tiles da $SRC_ROOT → $DST_ROOT" # Scorri tutte le tile z/x/y.png in tutte le sottocartelle find "$SRC_ROOT" -type f -name '*.png' | while read -r TILE; do # TILE = tiles_italy_new////.png REL="${TILE#$SRC_ROOT/}" # ///.png DEM="${REL%%/*}" # REST="${REL#*/}" # //.png Z="$(echo "$REST" | cut -d'/' -f1)" X="$(echo "$REST" | cut -d'/' -f2)" Y_FILE="$(echo "$REST" | cut -d'/' -f3)" OUT_DIR="$DST_ROOT/$Z/$X" OUT_PATH="$OUT_DIR/$Y_FILE" mkdir -p "$OUT_DIR" if [ -f "$OUT_PATH" ]; then echo "[WARN] Tile già esistente, lascio la prima: $OUT_PATH" continue fi cp "$TILE" "$OUT_PATH" done echo "[INFO] Merge completato in $DST_ROOT"