How do I re-zip/compress an expanded IDML file

1.1k Views Asked by At

I have an IDML file that I unzipped. I now want to compress the expanded folder back into an IDML file. I have access to a Mac or Linux machine.

What are the ways I can do this?

Zipping the file using zip (command line) or with Keka, BetterZip or Archive Utility don't work. InDesign issues the error:

Cannot open the file. Adobe InDesign may not support the file format, a plug-in that supports the file format may be missing, or the file may be open in another application.

2

There are 2 best solutions below

0
Eli On

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. zip -X0 'myfile.idml' mimetype

  2. Then they add the rest of the files/folders into the zip archive, this time with full compression. zip -rDX9 "myfile.idml" * -x "*.DS_Store" -x mimetype


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.

Source: http://indesignsecrets.com/topic/how-do-i-re-zipcompress-an-expanded-idml-file

A big thanks to Chuck Weger and David Blatner at http://indesignsecrets.com

0
léo On

From within InDesign

  1. use this jsx script to expand an IDML
//DESCRIPTION: Expands an IDML file into folder format
ExpandIDML();
function ExpandIDML(){
    var fromIDMLFile = File.openDialog("Please Select The IDML File to unpackage");
    if(!fromIDMLFile){return}
    var fullName = fromIDMLFile.fullName;
    fullName = fullName.replace(/\.idml/,"");
    var toFolder = new Folder(fullName);
    app.unpackageUCF(fromIDMLFile,toFolder);
}
  1. And that one to produce an IDML package:
//DESCRIPTION:Produces an IDML package from the contents of a directory:
CreateIDML();
function CreateIDML(){
    var fromFolder = Folder.selectDialog("Please Select The Folder to package as IDML");
    if(!fromFolder){return}
    var fullName = fromFolder.fullName;
    // var name = fromFolder.name;
    // var path = fromFolder.path;
    var toIDMLFile = new File(fullName+".idml");
    app.packageUCF(fromFolder,toIDMLFile);
}