#!/bin/bash # Check if input is provided if [ -z "$1" ]; then echo "Usage: $0 DIRECTORY" exit 1 fi DIRECTORY=$1 # Check if directory exists if [ ! -d "$DIRECTORY" ]; then echo "Error: Directory does not exist." exit 1 fi # Set variables IMAGE_ DIR="$DIRECTORY" OUTPUT_FILE="index.html" # Generate gallery with captions count=1 for img in $IMAGE_DIR/*.{jpg,jpeg,png,gif,webp}; do if [ -f "$img" ]; then filename=$(basename "$img") caption_file="${filename%.*}.txt" # Read caption if available, otherwise use default if [ -f "$caption_file" ]; then caption=$(cat "$caption_file") else caption="" fi echo "
" >> $OUTPUT_FILE echo "
\"$caption\"
" >> $OUTPUT_FILE echo "
$caption
" >> $OUTPUT_FILE echo "
" >> $OUTPUT_FILE count=$((count+1)) fi done # Add closing tags for the gallery cat >> $OUTPUT_FILE < EOL # Add lightbox overlays with captions count=1 for img in $IMAGE_DIR/*.{jpg,jpeg,png,gif,webp}; do if [ -f "$img" ]; then filename=$(basename "$img") caption_file="${filename%.*}.txt" if [ -f "$caption_file" ]; then caption=$(cat "$caption_file") else caption="" fi echo "