kicad:svg2pdf-dgxmessage
no way to compare when less than two revisions
Differences
This shows you the differences between two versions of the page.
— | kicad:svg2pdf-dgxmessage [2013/06/26 02:22] (current) – created mithat | ||
---|---|---|---|
Line 1: | Line 1: | ||
+ | <file bash svg2pdf-dgxmessage> | ||
+ | #!/bin/bash | ||
+ | ######################################################################## | ||
+ | # This program is free software: you can redistribute it and/or modify | ||
+ | # it under the terms of the GNU General Public License as published by | ||
+ | # the Free Software Foundation, either version 3 of the License, or | ||
+ | # (at your option) any later version. | ||
+ | # | ||
+ | # This program is distributed in the hope that it will be useful, | ||
+ | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
+ | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | ||
+ | # GNU General Public License for more details. | ||
+ | # | ||
+ | # You should have received a copy of the GNU General Public License | ||
+ | # along with this program. | ||
+ | ######################################################################## | ||
+ | |||
+ | # Copyright (C) 2013 Mithat Konar < | ||
+ | |||
+ | # DESTRUCTIVELY convert all svg files in working directory to pdf. | ||
+ | # Source file extension is case sensitive! | ||
+ | |||
+ | # Requires inkscape, gxmessage|xmessage. | ||
+ | |||
+ | EXT=.svg | ||
+ | OPTIONS="" | ||
+ | |||
+ | SCRIPTNAME=" | ||
+ | |||
+ | if which gxmessage > /dev/null ; then | ||
+ | XMESSAGE=" | ||
+ | YES_BUTTON=" | ||
+ | NO_BUTTON=" | ||
+ | else | ||
+ | XMESSAGE=xmessage | ||
+ | YES_BUTTON=" | ||
+ | NO_BUTTON=" | ||
+ | fi | ||
+ | |||
+ | # Make list of files to be processed. | ||
+ | FILES=$(ls -1 *${EXT} 2>/ | ||
+ | |||
+ | # Get confirmation from user to continue. | ||
+ | $XMESSAGE \ | ||
+ | -buttons " | ||
+ | -default " | ||
+ | " | ||
+ | |||
+ | $FILES" | ||
+ | |||
+ | # Make a temp file to store batch commands. | ||
+ | CMDFILE=$(mktemp) || { $XMESSAGE " | ||
+ | |||
+ | # Build up the list of commands in temp file. | ||
+ | for file in $FILES | ||
+ | do | ||
+ | base=$(basename $file ${EXT}) | ||
+ | echo " | ||
+ | done | ||
+ | |||
+ | # Process commands in a batch. | ||
+ | $XMESSAGE " | ||
+ | pid=$! | ||
+ | DISPLAY= inkscape ${OPTIONS} --shell < $CMDFILE | ||
+ | rm -f $CMDFILE | ||
+ | kill $pid | ||
+ | |||
+ | # Delete old files. | ||
+ | # Since inkscape exits with 0 even with errors, we need to explicitly check | ||
+ | # for conversion before deleting originals. | ||
+ | rv=0 | ||
+ | not_deleted="" | ||
+ | for file in $FILES | ||
+ | do | ||
+ | base=$(basename $file ${EXT}) | ||
+ | if [[ -f ${base}.pdf ]]; then | ||
+ | rm $file | ||
+ | else | ||
+ | not_deleted=" | ||
+ | $file" | ||
+ | rv=1 | ||
+ | fi | ||
+ | done | ||
+ | |||
+ | if [[ " | ||
+ | $XMESSAGE \ | ||
+ | "The following files were not deleted: | ||
+ | $not_deleted" | ||
+ | fi | ||
+ | |||
+ | exit $rv | ||
+ | |||
+ | </ |
kicad/svg2pdf-dgxmessage.txt · Last modified: 2013/06/26 02:22 by mithat