Skip to main content
Participating Frequently
October 8, 2023
Answered

Unzip passwrod protected file using InDesign JavaScript

  • October 8, 2023
  • 4 replies
  • 2432 views

Hi All,

 

Is there a way to unzip a password-protected file using InDesign JavaScript?

 

Please provide some examples if possible.

 

Thanks,

Shonky

This topic has been closed for replies.
Correct answer Peter Kahrel

Google this:

javascript unzip password

And you'll get the answer(s) you're looking for. You're not going to like them very much I don't think but that's your lot.

4 replies

Peter Kahrel
Community Expert
Peter KahrelCommunity ExpertCorrect answer
Community Expert
October 18, 2023

Google this:

javascript unzip password

And you'll get the answer(s) you're looking for. You're not going to like them very much I don't think but that's your lot.

Peter Kahrel
Community Expert
Community Expert
October 16, 2023

You can unzip a zip file using unpackageUCF():

app.unpackageUCF (
  File ('myZip.zip'),
  Folder ('d:/unzipped/')
);

Though probably password-protected zip files will be refused, but that will be the case with all unpackers. You'll have to look for a utility that allows a password as an input parameter, and you'll have to get the password from the party that produced the zip file.

Veera_IdSAuthor
Participating Frequently
October 18, 2023

Thanks Peter! it's working fine for files without a password. Do you have any suggestion for any utility that support password, I am unable to find out. I just got zip.js but it's not working with InDesign and getting attached error.

Robert at ID-Tasker
Legend
October 18, 2023

What is wrong with my example? 

 

You just need to find unzipping tool, check params for it to unzip password protected files and then build string to use in my example?

 

Similar principle for Mac - you just need to Google it. 

 

Robert at ID-Tasker
Legend
October 15, 2023

There are some examples for Windows:

 

https://stackoverflow.com/questions/10186813/how-to-run-cmd-exe-with-parameters-from-javascript

 

Something similar should be somewhere for Mac. 

 

Veera_IdSAuthor
Participating Frequently
October 15, 2023

Thanks Robert!

Can you please provide example with unzip with password?

brian_p_dts
Community Expert
Community Expert
October 16, 2023

You would have to use an external language that can perform the unzip function then call an Extendscript routine on the unzipped packaged.

James Gifford—NitroPress
Legend
October 8, 2023

A lot of files are actually ZIP archives (EPUB, MS Office, etc.) and have to be accessed through an archive opener. I'm pretty sure there are standard code examples and library routines for both regular ZIP and PW-protected ZIP files out there; not sure if they mesh with ID's version of things.

 

I've been looking for a good module to do just that, for other purposes, preferably with seamless PW control built in. Haven't found one, but I'm feeble on JS, my programming era being a while back.

Participating Frequently
October 12, 2023

Thanks James for your reply!

 

Zip and Unzip using InDesign JavaScript is possible but I am looking if we can extract a PW protected zip file using InDesign JavaScript.

 

Thanks,

Shonky

leo.r
Community Expert
Community Expert
October 12, 2023

If you're on Mac then you can use the unzip shell command. I don't know if shell scripts can be called directly from JavaScript, if not then you'll need to use doScript command in JavaScript to call do shell script AppleScript.