-
Notifications
You must be signed in to change notification settings - Fork 1
/
epubToEpub.sh
46 lines (40 loc) · 880 Bytes
/
epubToEpub.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
#!/bin/bash
SAVEIFS=$IFS
IFS=$(echo -en "\n\b")
# non-unicode to unicode conversion
# of NCERT ePathShala epub file to unicode epub file
# capturing the entire formatting
# Usage : ./runepub.sh <filename_without_extension> <option>
# filename_without_extension : fname if document us fname.epub
# option : 1 :- for walkman chanakya
# 2 :- for user uploaded mapping
if [ -d $1 ]
then
rm -rf $1
fi
unzip $1.epub -d $1
if [ $? -ne 0 ]
then
echo "---------- Corrupted file: "$1".epub -----------"
rm $1.epub
exit 0
fi
# sudo chmod -R 777 $1
chap=$(find -name "*.html" -or -name "*.xhtml")
for ch in $chap
do
echo '==================='
echo $ch
touch temp.txt
python translateEpubRawFile.py $ch $2 > temp.txt
cp temp.txt $ch
rm temp.txt
done
mkdir epubout
cd $1
zip -r $1n.epub *
cp $1n.epub ../epubout/$1.epub
cd ..
# chmod 777 $1out.epub
rm -rf $1
IFS=$SAVEIFS