Thanks to Harbs for pointing out the packageUCF/unpackageUCF methods. They are missing from the ESTK object model, at least mine. I first thought you were using a plugin until I found them covered in the IDML cookbook ...
Also thanks to Shane for the droplet (I'm sometimes too quick with Terminal), besides I learned you could use "ditto" instead of zip/unzip.
Dirk_Becker@adobeforums.com wrote:
> Thanks to Harbs for pointing out the packageUCF/unpackageUCF methods. They are missing from the ESTK object model, at least mine.
>
Hmm. So they are! I never tried looking in the OMV for them. Would you
like to report that, or should I?
On 24/2/09 7:17 PM, "Dirk Becker" <member@adobeforums.com> wrote:<br /><br />> You could use the command line (Terminal.app)<br /><br />C'mon, this is supposed to be a scripting forum, not the place to do things<br />the hard way ;-)<br /><br />Save this as a script app from Script Editor:<br /><br />on open filelist<br /> repeat with anitem in filelist<br /> set filePath to anitem as text<br /> set theSource to quoted form of POSIX path of filePath<br /> if (filePath ends with ".idml") then -- unzip<br /> set theDest to quoted form of POSIX path of ((text 1 thru -6 of<br />filePath) & ":")<br /> do shell script ("ditto -x -k " & theSource & " " & theDest)<br /> else if filePath ends with ":" then -- zip up<br /> set theDest to quoted form of POSIX path of ((text 1 thru -2 of<br />filePath) & "+.idml")<br /> do shell script ("ditto -c -k --norsrc --noextattr " & theSource<br />& " " & theDest)<br /> end if<br /> end repeat<br />end open<br /><br />Drag .idml files on to it and they'll be unzipped; drag folders, and they'll<br />be converted to .idml (with a + before the extension to distinguish them<br />from the originals).<br /><br />-- <br />Shane Stanley <sstanley@myriad-com.com.au><br />AppleScript Pro Sessions <a href=http://scriptingmatters.com/aspro>
Shane_Stanley@adobeforums.com wrote:<br />> C'mon, this is supposed to be a scripting forum, not the place to do things<br />> the hard way ;-)<br />> <br /><br />Yeah, but it's an *InDesign* scripting forum, so we shouldn't be <br />dragging and dropping at all... <VGB><br /><br />-- <br />Harbs<br />http://www.in-tools.com
Here's how to do it with scripting (my preferred method)...
function ExpandIDML(fromIDMLFile){//Expands an IDML file into folder format
if(! fromIDMLFile){return null}
var fullName = fromIDMLFile.fullName;
fullName = fullName.replace(/\.idml/,"");
var toFolder = new Folder( fullName );
app.unpackageUCF( fromIDMLFile, toFolder );
return toFolder;
}
function CreateIDML(fromFolder){//Produces an IDML package from the contents of a directory:
if(!fromFolder){return null}
var fullName = fromFolder.fullName;
var toIDMLFile = new File( fullName+".idml" );
app.packageUCF( fromFolder, toIDMLFile );
return toIDMLFile;
}
Assuming you have a folder INX on your desktop, with a file test.idml
This will extract the IDML into a folder "test":
unzip /Users/dave/Desktop/INX/test.idml -d /Users/dave/Desktop/INX/test
In OSX terminal.app you can use drag&drop instead of typing file names.
The option "-d" specifies the output folder. If you omit that, all the archive files will end up in your home directory.
This will rebuild the IDML:
cd /Users/dave/Desktop/INX/test
zip -r ../test2.idml *
The cd into the folder is required because this way the files will have the correct relative paths.
The option "-r" means recursive - add also the files contained within folders.
If you have the oXygen XML editor, go to Preferences/Archive, there add an entry for the ".idml" extension. Then oXygen can open IDML without going thru the unzip/zip cycle.
Rename the .hdml file to .zip, then use any program that can create/change zip files (Stuffit. etc) and put the xml back into the zip file, then rename .zip back to .hdml.
Let's say I create a little document and type "Hello World" into it.
I export as IDML and the result is a zip file (with the .idml extension). So I unzip it, find the stories.xml file and change the content to "Hello Ducky".
Now, what do I use to reconstitute the zip file? Using Leopard's Create Archive does seem to work.
I recently had an index with part numbers and UPC codes. Some of the UPC codes were incorrect so I had the client output the correct part numbers and UPC codes to a csv file. I saved the index to IDML and used grep in a text editor to find each part number and look up the correct UPC from the CSV file. After updating appropriate XML file from the IDML, I reopened it in InDesign and had my updated index.
I could have done this directly in the InDesign file with JavaScript, but I found it easier to do it on the XML file form the IDML file.