Created
March 8, 2025 10:51
-
-
Save black-dragon74/6f4dfe1124d848a7a3ac46d1eaa05d1b to your computer and use it in GitHub Desktop.
Convert Apple Books or iTunes Books to general EPUB format
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
for f in *.epub; do | |
if [ -d "$f" ]; then | |
echo "Converting: $f" | |
cd "$f" | |
find . -name "iTunesMetadata*.plist" -delete 2>/dev/null | |
zip -0X "../tmp.epub" mimetype >/dev/null | |
zip -rDX9 "../tmp.epub" * -x "*.DS_Store" -x mimetype >/dev/null | |
cd .. | |
rm -rf "$f" | |
mv tmp.epub "$f" | |
elif [[ $(unzip -l "$f" 2>/dev/null | grep iTunesMetadata) == "" ]]; then | |
echo "Already clean: $f" | |
else | |
echo "Unexpected file: $f" | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment