D****r 发帖数: 309 | 1 Cablire only convert 1 page, don't know why.
thanks in advacne! |
t******n 发帖数: 138 | 2 试一试calibre。
epub是html文件的zip打包?
【在 D****r 的大作中提到】 : Cablire only convert 1 page, don't know why. : thanks in advacne!
|
D****r 发帖数: 309 | 3 thanks.
I am already using calibre and the zipped package is all .txt files. |
D****r 发帖数: 309 | 4 seems the problem lies in charset/ encoding. |
D****r 发帖数: 309 | 5 我参考网上捣鼓了个小程序,请各位大侠指正:
我用的cygwin + iconv, ebook-convert.exe
先把zipped text file unzip to a directory.
------------
#!/bin/bash
# convert all txt files in current DIR into one ePub ---- by Donier
### Firstly convert all files into utf-8 charset ###
for f in *.txt
do
if test -f $f
then
echo -e "\nConverting $f"
CHARSET="$( file -bi "$f"|awk -F "=" '{print $2}')"
if [ "$CHARSET" != utf-8 ]
then
mv $f $f.old
iconv -f "$CHARSET" -t utf-8 $f.old > $f
# rm -f $f.old
fi
fi
done
### pack all text file into one html ####
html=output.html
echo "" > $html
echo "" >> $html
for file in *.txt ; do
echo "processing " $file " ... "
h1=$(echo $file | sed 's/\.txt$//i')
echo " Part" $h1 " " >> $html
while read line ; do
echo "$line " >> $html
done < $file
done
echo "" >> $html
echo "" >> $html
### convert html into epub
ebook-convert.exe output.html output.epub |