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

Unzip passwrod protected file using InDesign JavaScript

Community Beginner ,
Oct 08, 2023 Oct 08, 2023

Copy link to clipboard

Copied

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

Views

1.2K

Translate

Translate

Report

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.

Votes

Translate

Translate
Community Expert ,
Oct 08, 2023 Oct 08, 2023

Copy link to clipboard

Copied

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.


┋┊ InDesign to Kindle (& EPUB): A Professional Guide, v3.1 ┊ (Amazon) ┊┋

Votes

Translate

Translate

Report

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

Copy link to clipboard

Copied

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

Votes

Translate

Translate

Report

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

Copy link to clipboard

Copied

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.

Votes

Translate

Translate

Report

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

Copy link to clipboard

Copied

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.

Votes

Translate

Translate

Report

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

Copy link to clipboard

Copied

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

 

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

Votes

Translate

Translate

Report

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

Copy link to clipboard

Copied

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. 

 

Votes

Translate

Translate

Report

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

Copy link to clipboard

Copied

Thanks Robert!

Can you please provide example with unzip with password?

Votes

Translate

Translate

Report

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

Copy link to clipboard

Copied

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

 

Votes

Translate

Translate

Report

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

Copy link to clipboard

Copied

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

Votes

Translate

Translate

Report

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

Copy link to clipboard

Copied

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.

Votes

Translate

Translate

Report

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

Copy link to clipboard

Copied

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.

Votes

Translate

Translate

Report

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

Copy link to clipboard

Copied

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.

Votes

Translate

Translate

Report

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

Copy link to clipboard

Copied

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. 

 

Votes

Translate

Translate

Report

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

Copy link to clipboard

Copied

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...

 

Votes

Translate

Translate

Report

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

Copy link to clipboard

Copied

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.

Votes

Translate

Translate

Report

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