#!/usr/bin/env bash set -euo pipefail # Carpeta de imágenes y archivo HTML a actualizar IMG_DIR="ARTIVISMO_THS" HTML="index.html" # Extensiones soportadas (añade/quita lo que quieras) shopt -s nullglob nocaseglob IMGS=("$IMG_DIR"/*.{jpg,jpeg,png,webp,gif}) # Construye el HTML de la galería en un buffer TMP="$(mktemp)" { echo '' echo '
' for f in "${IMGS[@]}"; do base="${f##*/}" # nombre con extensión title="${base%.*}" # sin extensión title="${title//_/ }" title="${title//-/ }" # mayúscula inicial simple title="$(echo "$title" | awk '{for(i=1;i<=NF;i++){ $i=toupper(substr($i,1,1)) substr($i,2) } ; print }')" cat < $title

$title

EOF done echo '
' echo '' } > "$TMP" # Reemplaza el bloque entre marcadores en index.html awk -v RS= -v ORS="" -v repl="$(sed 's/[&/\]/\\&/g' "$TMP")" ' { gsub(//, repl); print } ' "$HTML" > "$HTML.tmp" && mv "$HTML.tmp" "$HTML" rm -f "$TMP" echo "Galería actualizada con ${#IMGS[@]} imágenes en $HTML"