Skip to content

Instantly share code, notes, and snippets.

@techcaotri
Created September 6, 2025 03:07
Show Gist options
  • Select an option

  • Save techcaotri/3d4da9fac539c1accc3806ba3069afa3 to your computer and use it in GitHub Desktop.

Select an option

Save techcaotri/3d4da9fac539c1accc3806ba3069afa3 to your computer and use it in GitHub Desktop.
Script to batch-convert Dot files (e.g. created by Scitools Understand) to drawio
#!/usr/bin/env bash
set -euo pipefail
DOT_DIR="${DOT_DIR:-./ControlFlow_Reports/flowcharts_dot}"
OUTPUT="${OUTPUT:-./ControlFlow_Reports/drawio}"
# Ensure these are exported or set before running
: "${DOT_DIR:?Need to set DOT_DIR}"
: "${OUTPUT:?Need to set OUTPUT}"
# Create output directory if not existing
mkdir -p "$OUTPUT"
# Loop through all .dot files
for src in "$DOT_DIR"/*.dot; do
# Skip if no .dot files present
[[ -e "$src" ]] || continue
# Derive basename and destination path
base=$(basename "$src" .dot)
dest="$OUTPUT/${base}.xml"
echo "Converting '$src' → '$dest'…"
graphviz2drawio "$src" -o "$dest"
echo " ✔ Generated '$dest'"
done
echo "All done!"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment