Skip to content

Instantly share code, notes, and snippets.

@rnikitin
Created February 9, 2025 19:55
Show Gist options
  • Save rnikitin/7059b4f56e1221dbfc3b29533fcf31f4 to your computer and use it in GitHub Desktop.
Save rnikitin/7059b4f56e1221dbfc3b29533fcf31f4 to your computer and use it in GitHub Desktop.
for f in *.epub; do if [ -d "$f" ]; then (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 && echo "Converting: $f") && rm -rf "$f" && mv tmp.epub "$f"; elif [[ $(unzip -l "$f" 2>/dev/null | grep iTunesMetadata) == "" ]]; then echo "Already clean: $f"; else echo "Converting: $f"; fi; done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment