+#!/bin/bash
+cd "${0%/*}"; if [ "$1" != "T" ]; then gnome-terminal -- "$0" T; exit; fi;
+cd ..
+
+# Function to export org to html using emacs in batch mode
+export_org_to_html() {
+ local org_file=$1
+ local dir=$(dirname "$org_file")
+ local base=$(basename "$org_file" .org)
+ (
+ cd "$dir" || return 1
+ local html_file="${base}.html"
+ if [ -f "$html_file" ]; then
+ rm -f "$html_file"
+ fi
+ echo "Exporting: $org_file → $dir/$html_file"
+ emacs --batch -l ~/.emacs --visit="${base}.org" --funcall=org-html-export-to-html --kill
+ if [ $? -eq 0 ]; then
+ echo "✓ Successfully exported $org_file"
+ else
+ echo "✗ Failed to export $org_file"
+ return 1
+ fi
+ )
+}
+
+echo "🔍 Searching for .org files in doc/ ..."
+echo "======================================="
+
+mapfile -t ORG_FILES < <(find doc -type f -name "*.org" | sort)
+
+if [ ${#ORG_FILES[@]} -eq 0 ]; then
+ echo "❌ No .org files found!"
+ echo ""
+ echo "Press ENTER to close this window."
+ read
+ exit 1
+fi
+
+echo "Found ${#ORG_FILES[@]} .org file(s):"
+printf '%s\n' "${ORG_FILES[@]}"
+echo "======================================="
+
+SUCCESS_COUNT=0
+FAILED_COUNT=0
+
+for org_file in "${ORG_FILES[@]}"; do
+ export_org_to_html "$org_file"
+ if [ $? -eq 0 ]; then
+ ((SUCCESS_COUNT++))
+ else
+ ((FAILED_COUNT++))
+ fi
+done
+
+echo "======================================="
+echo "📊 SUMMARY:"
+echo " ✓ Successful: $SUCCESS_COUNT"
+echo " ✗ Failed: $FAILED_COUNT"
+echo " Total: $((SUCCESS_COUNT + FAILED_COUNT))"
+echo ""
+
+echo "📤 Uploading to server..."
+rsync -avz --delete -e 'ssh -p 10006' doc/ n0@www3.svjatoslav.eu:/mnt/big/projects/fifth/
+
+if [ $? -eq 0 ]; then
+ echo "✓ Upload completed successfully!"
+else
+ echo "✗ Upload failed!"
+fi
+
+echo ""
+echo "Press ENTER to close this window."
+read