# automating my gemlog index on sdf so this iis the second post and I have updated my script to update the gemlog. ``` cat << 'EOF' > update-gemlog.sh #!/bin/bash GEMLOG_DIR="gemlog" INDEX_FILE="${GEMLOG_DIR}/index.gmi" # Write Header cat << 'HEADER' > "$INDEX_FILE" # Field Notes & Gemlog Welcome to my log. Entries are listed in reverse chronological order. HEADER # Find all .gmi files except index.gmi, extract title or filename, and sort reverse-chronologically for file in $(ls -r ${GEMLOG_DIR}/*.gmi 2>/dev/null); do basename=$(basename "$file") # Skip the index itself if [ "$basename" = "index.gmi" ]; then continue fi # Read the first heading (# Title) or fall back to filename title=$(grep -m 1 "^# " "$file" | sed 's/^# //') if [ -z "$title" ]; then title="$basename" fi echo "=> ${basename} ${title}" >> "$INDEX_FILE" done # Write Footer cat << 'FOOTER' >> "$INDEX_FILE" => / Back to main capsule FOOTER echo "Gemlog index updated successfully!" EOF chmod +x update-gemlog.sh ```