Search code examples
macoszip

Unzipping .zip file on Mac (GUI vs. Command line)


I have a password-protected .zip file that I need to decrypt and unzip on a Mac.

If I go to the file in Finder, double-click on it, enter the password when prompted, it decrypts and unzips the file without issue.

However if I open terminal and try to unzip it using the following command line, it gives and error:

unzip targetfile.CSV.zip
Archive:  targetfile.CSV.zip
   skipping: targetfile.CSV  unsupported compression method 99

I understand that the error itself means that the compression algorithm isn't supported but something within the OS must be able to decrypt/unzip the file since it was able to handle it through the GUI (and, yes, I need to do it through the command line). I probably will not be allowed to use a third-party tool like 7zip to unlock it.

How do I get the command line to decrypt/unzip the file?


Solution

  • 99 means that the entry is encrypted, not that it is using an unsupported compression method. The 99 hides the actual compression method, which is found elsewhere after decryption.

    You can try the 7-zip command-line executable. That should be able to decrpyt and extract the zip file.

    Alternatively you can create an AppleScript to do the action using Finder, and then make a command-line executable out of that using the osascript command.