Skip to content

Instantly share code, notes, and snippets.

@JLeine
Created April 19, 2023 12:53
Show Gist options
  • Save JLeine/65e50d3f4fc246eca6ea35cc2aa7ebb5 to your computer and use it in GitHub Desktop.
Save JLeine/65e50d3f4fc246eca6ea35cc2aa7ebb5 to your computer and use it in GitHub Desktop.
Convert all drawio Files into PNGs and embedded the diagram into it
#!/bin/bash
# check if the directory path is provided
if [[ $# -eq 0 ]]
then
echo "Usage: $0 <directory_path>"
exit 1
fi
# set the path to the drawio command line tool
DRAWIO_CLI=/Applications/draw.io.app/Contents/MacOS/draw.io
# loop through all files in the specified directory and its subfolders
find "$1" -type f -name "*.drawio" | while read file
do
# generate the name of the output PNG file
output="${file%.drawio}.drawio.png"
# use the drawio command line tool to convert the file
$DRAWIO_CLI -x -f png -e -o $output "$file"
# print a message indicating that the conversion is complete
echo "Converted $file to $output"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment