View Single Post
Old 03-12-2024, 07:02 AM   #21
technicaltitch
Member
technicaltitch began at the beginning.
 
Posts: 20
Karma: 10
Join Date: Jul 2011
Device: Sony PRS 350
I didn't like losing the contents index and page breaks of converting to rtf and back. I'm running on Ubuntu, this also works on macOs. My reader stopped applying `img {display:none;}`, I needed CLI, this just deletes all the images then rezips:

```
# takes the recipe name as $1

# create epub as, eg, 20240312_The Register.epub, with images:
ebook-convert "$1".recipe $(date +%Y%m%d)_"$1".epub
# make working directory
mkdir "$(date +%Y%m%d)_$1"
# unzip epub
unzip "$(date +%Y%m%d)_$1.epub" -d "$(date +%Y%m%d)_$1"
cd "$(date +%Y%m%d)_$1"
#delete all images
find . -name "*.jpg" -exec rm {} +
find . -name "*.png" -exec rm {} +
# delete old epub
rm "../$(date +%Y%m%d)_$1.epub"
#rezip
zip -X0 "../$(date +%Y%m%d)_$1_noimg.epub" mimetype
zip -X9Dr "../$(date +%Y%m%d)_$1_noimg.epub" * -x mimetype
# delete working directory
rm -r "$(date +%Y%m%d)_$1"
```

Save this as `download_without_images.sh`, `chmod +x` it, then call, eg:

./download_without_images.sh "The Register"

Last edited by technicaltitch; 03-12-2024 at 07:05 AM.
technicaltitch is offline   Reply With Quote