-
Notifications
You must be signed in to change notification settings - Fork 1
/
GUI.sh
executable file
·94 lines (76 loc) · 2.9 KB
/
GUI.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
#!/bin/sh
#Author: Johannes Deml, Johannes Kalliauer
#Source: http://www.inkscapeforum.com/viewtopic.php?t=16743
#Download: http://ge.tt/7C8JFmF1/v/0?c
#Download date: 2017-10-29
#last Changes: (by Johannes Kalliauer)
#2017-10-29 11h06 defined inkscape alias (Johannes Kalliauer)
echo
#needed if in the bashrc ist defined: export alias inkscape='/cygdrive/c/Program\ Files/Inkscape/inkscape.com'
if [ -z ${inkscape+x} ]; then
echo not def
else
echo $inkscape
alias inkscape=$inkscape
fi
#Input parameters:
#alias inkscape='/cygdrive/c/Program\ Files/Inkscape/inkscape.com' #2017-10-29 11h06 (by Johannes Kalliauer)
#alias inkscape.exe='/cygdrive/c/Program\ Files/Inkscape/inkscape.exe'
sourceType="svg"
outputType="svg"
valid=1
count=0
validInput1="svg"
validInput2="pdf"
validInput3="eps"
validOutput1="eps"
validOutput2="pdf"
validOutput3="png"
validOutput4="svg"
validOutput5="plain-svg"
#echo "This script allows you to convert all files in this folder from one file type to another."
#valid=0
while [ "$valid" != "1" ]
do
echo "Allowed file types for source: $validInput1, $validInput2, $validInput3"
read -p "What file type do you want to use as a source? " sourceType
if [ "$sourceType" = "$validInput1" ] || [ "$sourceType" = "$validInput2" ] || [ "$sourceType" = "$validInput3" ]; then
valid=1
else
echo "Invalid input! Please use one of the following: $validInput1, $validInput2, $validInput3"
fi
done
#valid=0
while [ "$valid" != "1" ]
do
echo "Allowed file types for output: $validOutput1, $validOutput2, $validOutput3"
read -p "What file type do you want to convert to? " outputType
if [ "$outputType" = "$validOutput1" ] || [ "$outputType" = "$validOutput2" ] || [ "$outputType" = "$validOutput3" ] || [ "$outputType" = "$validOutput4" ] || [ "$outputType" = "$validOutput5" ]; then
valid=1
else
echo "Invalid input! Please use one of the following: $validOutput1, $validOutput2, $validOutput3"
fi
done
for fileSource in *.$sourceType
do
if [ -f "$fileSource" ]; then
count=$((count+1))
file=$(echo $fileSource | cut -d'.' -f1)
echo $count". "$fileSource" -> "${file}g.$outputType
if [ "$outputType" = "png" ];then
read -p "With what dpi should it be exported (e.g. 300)? " dpi
inkscape $fileSource --export-$outputType=$file.$outputType --export-dpi=$dpi
elif [ "$outputType" = "svg" ];then
cp ./${fileSource} ./${file}g.svg
mv ./${fileSource} ./${file}.xml
inkscape --with-gui ./${file}g.svg --verb=DialogDocumentProperties --export-plain-svg=${file}gG.svg --verb=FileSave --verb=FileClose --verb=FileQuit
#scour -i ./${file}g.svg -o ./${file}gs.svg --disable-style-to-xml --keep-unreferenced-defs --indent=space --nindent=1
#mv ./${file}g.svg ./${file}g.xml
else
inkscape $fileSource --export-$outputType=$file.$outputType
fi
else
echo "no file $fileSource found!"
fi
done
echo "$count file(s) converted!"