-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathzenityPandoc.sh
executable file
·48 lines (37 loc) · 1.15 KB
/
zenityPandoc.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
#!/bin/bash
if ! command -v zenity; then
echo "you need to install zenity to use this script. Exiting."
exit
fi
if ! command -v pandoc; then
echo "you need to install pandoc to use this script. Exiting."
exit
fi
if [ $1 ] && [ -s $1 ]; then #check if first paramter is there and is an existing file
SOURCEFILE=$1
else
if ! SOURCEFILE=$(zenity --file-selection --title="Choose the file you want to convert using pandoc"); then
exit
fi
fi
if ! CONVERTTO=$(zenity --list --title="choose target format" --column="Format" --column="Text" \
odt "Open Document" \
docx "docx MS Office" \
mediawiki "mediawiki"\
markdown "markdown"\
asciidoc "Ascii Doc"\
html "html"\
latex "LaTeX"\
context "ConTeXt" ); then
exit
fi
if test -f $SOURCEFILE.$CONVERTTO; then
if ! OVERWRITE=$(zenity --question --text="File $FILE.$CONVERTTO exists already, overwrite?"); then
exit
fi
fi
TARGETFULLPATH=$SOURCEFILE.$CONVERTTO
TARGETNAME=${TARGETFULLPATH##*/}
SOURCENAME=${SOURCEFILE##*/}
pandoc $SOURCEFILE -t $CONVERTTO -o $TARGETFULLPATH
zenity --info --text="Converted $SOURCENAME to format $CONVERTTO , saved as $TARGETNAME";