The problem with regular zip is that the zip archive contains a “mimetype” file that shouldn’t be compressed if you want InDesign to identify the newly-created IDML. So the way you have to re-zip the file (and the way the ePub scripts work) is like this:
1. They first create a zip archive which contains only the mimetype file, uncompressed.
2. Then they add the rest of the files/folders into the zip archive, this time with full compression.
In shell script terms, the ePub scripts do this (assuming the current directory is the one containing all the IDML contents):
zip -X0 ‘myfile.idml’ mimetype # create the zip archive ‘myfile.idml’, containing only the ‘mimetype’ file with no compression
zip -rDX9 “myfile.idml” * -x “*.DS_Store” -x mimetype # add everything else to the ‘myfile.idml’ archive, EXCEPT .DS_Store files and the ‘mimetype’ file (which is already there from the previous step)
To save you time reading the zip man page, here’s what all these options mean:
-X = “no extra” — do not save extra file attributes like user/group ID for each file
-0 = “compression level zero” — no compression
-r = “recurse paths” — go through everything in the directory, including nested subfolders
-D = “no directory entries” — don’t put special stuff in the zip archive for directories
-9 = “compression level 9 (optimal)”
-x = “exclude these files”
Follow this voodoo, and you should be able to create legal IDML files.
It creates a drag and drop applet. The first time you run it you may need to double-click it, or right-click and choose Open from the context menu (Just to tell the Mac that it’s okay to run this new app.) But after that, you can just drag an IDML file on it to turn it to a folder. Then drag the folder back on it and it converts to an IDML file (with a + symbol to indicate it’s been changed).