View Single Post
Old 07-16-2019, 05:53 AM   #1
BlindBandit
Junior Member
BlindBandit began at the beginning.
 
Posts: 3
Karma: 10
Join Date: Jul 2019
Device: iPhone SE
Guide: Removing iTunes metadata from ePub

I recently came across a problem when adding my ebook collection to my iPhone via iTunes and thought the knowledge I gained finding a solution might be useful for others.

I used a program called calibre to edit an ePub's metadata (title and author) and then added it to iTunes to copy onto my iPhone. But when I did, iTunes was still using the old metadata with the old title and author, not the new ones.

After a lot of digging (and this useful post) I managed to figure out why. ePubs are an archive with a bunch of smaller files inside of it, including one file called content.opf that contains the metadata. When an ePub is added to iTunes, it doesn't read its metadata from content.opf; it reads it from another file, iTunesMetadata.plist. If the iTunesMetadata.plist file doesn't exist, iTunes will create one based off content.opf and put it inside the original ePub.

That means when you first add an ePub to iTunes, its metadata will match properly because iTunesMetadata.plist is being created for the first time using the up-to-date metadata... but if you ever change the ePub's metadata, you'll only be changing content.opf and iTunes will continue to use the old, unchanged metadata from iTunesMetadata.plist.

The solution is to use rar or zip or some other archive program to delete the iTunesMetadata.plist file inside the .epub file before adding the ePub to iTunes. If you do that, iTunes will be forced to create a new iTunesMetadata.plist file with the latest metadata.

But if you're like me and have a huge library, doing this manually for every file would take a long time. So I wrote a Windows batch script (included below) to quicken the process. I've gotten into the habit of running this script every time before I add new ebooks to iTunes and it has saved me a lot of headaches.

To run it, you'll need to download zip.exe (I got it from here, but there's plenty of other places to get it) and save it somewhere on your computer.

Then create a .bat batch file with this text inside:

Code:
FOR /R "C:\Users\Jordan\Calibre Library" %%G IN (*.epub) DO "C:\CommandLineTools\zip.exe" -d "%%G" iTunesMetadata.plist
PAUSE
Note: If you're running this from the command line using the cmd.exe command prompt instead of running it from a .bat batch script, replace the %%G parts with %G.

"C:\Users\Jordan\Calibre Library" is the location of my ePub collection, and "C:\CommandLineTools\zip.exe" is the location of my zip.exe (as explained above). Change these path locations to match wherever your ePub collection and zip.exe are located.

Hope this helps someone
BlindBandit is offline   Reply With Quote