@eschwartz:
Unfortunately, your script doesn't work, because kindlestrip.py requires two parameters: the original file and the stripped file. It also doesn't work with file names that contain spaces.
This script actually works:
Code:
#!/bin/bash
# IFS change for file names with spaces in them
SAVEIFS=$IFS
IFS=$(echo -en "\n\b")
# delete old log
rm -f conversion.log
# process all .mobi files in folder
for i in *.mobi; do
python kindlestrip.py "$i" ${i%%.*}.new
ret=$?
if [ $ret -ne 0 ]; then
echo "$i" was NOT stripped >> conversion.log
else
rm $i
mv ${i%%.*}.new ${i%%.*}.mobi
echo "$i" was stripped >> conversion.log
fi
done
# restore default IFS
IFS=$SAVEIFS
@Thalia Helikon: You no longer need to use kindlestrip.py, because there's a recently discovered undocumented
kindlegen parameter that'll prevent
kindlegen from attaching the source files,
-dont_append_source. You could use it in a shell script file to convert multiple .epubs with KindleGen:
Code:
#!/bin/bash
# IFS change for file names with spaces in them
SAVEIFS=$IFS
IFS=$(echo -en "\n\b")
# delete old log
rm -f conversion.log
# process all .epub files in folder
for i in *.epub; do
kindlegen -dont_append_source "$i" >> conversion.log
ret=$?
if [ $ret -ne 0 ]; then
echo "$i" was NOT compiled. Error code: $ret >> conversion.log
fi
done
# restore default IFS
IFS=$SAVEIFS
(Of course, you'll also need to copy the kindlegen binary to
~/bin (or create a symbolic ink) and make the shell script executable.)