Apple Books (formerly iBooks) exports personal EPUBs as folders containing loose files and unwanted metadata like iTunesMetadata.plist, which Calibre can’t import directly. Cleaning these into standard ZIP-based EPUBs allows seamless transfer to Calibre for management and conversion.
This guide covers extraction, batch cleaning via terminal (with the provided script), and platform-specific solutions for Linux, macOS, and Windows.

Extracting EPUB Folders from Apple Books
Connect your iPhone, iPad, or Mac to a computer via USB.
On macOS or Windows with iTunes/Finder, locate books in ~/Library/Containers/com.apple.BKAgentService/Data/Documents/iBooks/Books (macOS) or the iTunes Mobile Applications folder (Windows).
Copy the entire folder for each book to a working directory—these are not ZIP files but directories mimicking EPUBs with extra Apple cruft.
AirDrop or Files app sharing from iOS also dumps these folders, ideal for bulk transfer without iTunes.
Batch Cleaning Script Explained
The provided bash script processes a directory of EPUB folders or corrupted ZIPs, stripping Apple metadata and repackaging into valid EPUBs.
Run it in Terminal (Linux/macOS) after cding to your books folder.
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;
doneIt deletes plists, zips mimetype first (EPUB spec), adds the rest excluding junk, and handles pre-zipped files with metadata.
Linux and macOS Instructions
Prerequisites: Install zip and unzip (usually pre-installed).
- Extract folders to
~/epubs/. - Open Terminal:
cd ~/epubs && chmod +x clean.sh(paste script into clean.sh first). - Run
./clean.sh—it processes all *.epub folders/files in seconds for hundreds of books.
Import cleaned EPUBs into Calibre via “Add books.” Linux users (e.g., Ubuntu) follow identically.
Windows Instructions
Windows lacks native bash, so use alternatives:
- WSL (Recommended): Enable Windows Subsystem for Linux, install Ubuntu, then run the script as on Linux. Access files via
/mnt/c/Users/YourName/epubs. - PowerShell Adaptation: Save as .ps1 and tweak (less reliable for recursive zips):
Get-ChildItem *.epub | ForEach-Object {
if (Test-Path $_ -PathType Container) {
Remove-Item "$_\iTunesMetadata*.plist" -Recurse -Force -ErrorAction SilentlyContinue
& cmd /c 'cd "$_" && ..\7z a -tzip -mx=9 -x!mimetype ..\tmp.epub mimetype && 7z a -tzip -mx=9 ..\tmp.epub * -x!"*.DS_Store" -x!mimetype'
Remove-Item $_ -Recurse; Move-Item tmp.epub $_
}
}Requires 7-Zip installed.
- GUI Tools: Drag folders to Calibre – some versions auto-clean simple cases – or use Epubor Ultimate (paid) for batch fixes.
Importing to Calibre and Troubleshooting
Add cleaned files to Calibre; it detects metadata automatically.
Polish with “Convert books” for MOBI/AZW3 if needed.
Common issues: DRM books won’t export (Apple-locked); test one first. If script fails, manually zip:
cd bookfolder && zip -0 ../clean.epub mimetype/ && zip -r ../clean.epub . -x mimetype/*
Your library is now Calibre-ready for multi-device sync.
