Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
8

Unzip passwrod protected file using InDesign JavaScript

Community Beginner ,
Oct 08, 2023 Oct 08, 2023

Hi All,

 

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

 

Please provide some examples if possible.

 

Thanks,

Shonky

TOPICS
Scripting
1.5K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , Oct 18, 2023 Oct 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.

Translate
Community Expert ,
Oct 08, 2023 Oct 08, 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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Oct 11, 2023 Oct 11, 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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Oct 11, 2023 Oct 11, 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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Oct 14, 2023 Oct 14, 2023

Thanks Leo! But I need it to work on Mac and Windows both. I found a Zip.js library, here is a link

https://gildas-lormeau.github.io/zip.js/

 

But I am unable to use it in InDesign, I hope someone expert here can help me.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Oct 15, 2023 Oct 15, 2023

I tried to inlcude zip.js in InDesign JavaScript and getting attached error.

 

I am not sure if zip.js compitable for InDesign JavaScript.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Oct 15, 2023 Oct 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. 

 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Oct 15, 2023 Oct 15, 2023

Thanks Robert!

Can you please provide example with unzip with password?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Oct 15, 2023 Oct 15, 2023

Everything depends on unzip tool you plan to use... 

 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Oct 16, 2023 Oct 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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Oct 17, 2023 Oct 17, 2023

Thanks Brian, I tried to use zip.js but it's not working in InDesign JavaScript, and not sure for any other external library which support InDesign.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Oct 16, 2023 Oct 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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Oct 17, 2023 Oct 17, 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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Oct 18, 2023 Oct 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. 

 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Oct 18, 2023 Oct 18, 2023

Maybe not a very straightforward answer - but an example how to execute shell command on Mac:

 

https://community.adobe.com/t5/indesign-discussions/is-it-possible-to-run-a-mac-os-shell-command-wit...

 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Oct 18, 2023 Oct 18, 2023
LATEST

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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines