Skip to main content
Participant
May 5, 2010
Question

How to zip files using javascript

  • May 5, 2010
  • 1 reply
  • 2263 views

I want to zip a folder using java script. Is there a way to do it? How does the "Export for Digital Editions" do it (Since ePub is essentially a zip)?

This topic has been closed for replies.

1 reply

May 7, 2010

Hi,

Try with following coding:

//----------------------------------------------
CreateZIP();

function CreateZIP(){
var fromFolder = Folder.selectDialog("Please Select The Folder to package as IDML");
if(!fromFolder)
{
    return
    }
var fullName = fromFolder.fullName;
var toZIPFile = new File( fullName+".zip" );
app.packageUCF( fromFolder, toZIPFile );
}

//----------------------------------------------

Thanks,

Praveen

May 7, 2010

app.packageUCF will work to create IDML files, but is not suited to make standard zip files. Don't ask me why, but it just doesn't work correctly with binary files.

Teus