Skip to content

Instantly share code, notes, and snippets.

@yude
Last active January 30, 2023 04:44
Show Gist options
  • Save yude/b1f15655bd0a477ff7093a8c7f216507 to your computer and use it in GitHub Desktop.
Save yude/b1f15655bd0a477ff7093a8c7f216507 to your computer and use it in GitHub Desktop.
#!/bin/sh
# This script is for macOS and GNU/Linux.
# Check if rsvg-convert is installed on the system.
if ! command -v rsvg-convert &> /dev/null
then
echo "コマンド rsvg-convert (librsvg) がインストールされていません。"
echo "Homebrew などのパッケージマネージャから導入してください。"
exit
fi
if ! command -v gs &> /dev/null
then
echo "コマンド gs がインストールされていません。"
echo "Homebrew などのパッケージマネージャから導入してください。"
exit
fi
mkdir pdf
find . -name '*.svg' | xargs basename -s .svg | xargs -I{} rsvg-convert -f pdf -o ./pdf/{}.pdf ./{}/{}.svg
PDF_FILES=`find . -name '*.pdf' -print0 | sort -z | xargs -0 echo`
CURRENT_DIR_NAME=${PWD##*/}
CURRENT_DIR_NAME=${CURRENT_DIR_NAME:-/}
gs -q -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -sOutputFile="${CURRENT_DIR_NAME}.pdf" ${PDF_FILES}
echo "PDF ファイルの出力が完了しました。"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment