Breaking out of the ZIP-CPGZ loop

I receive a lot of compressed archives, from a wide variety of different users.

Those who prefer the command-line (usually other developers) will TAR the directory then GZIP the TAR.

Most users are more comfortable with a GUI for archiving and wind up sending a ZIP file. With those it’s usually a quick double-click and onto the task at hand.

Usually.

Let’s say I receive an archive named, creatively, archive.zip. I double-click it but instead of an uncompressed archive named archive emerging out of the other end, I get this:

archive.zip.cpgz

Confused, I double-click again and a third file appears:

archive 2.zip

Or, a second copy of the original file I received. This, my friends, is the ZIP-CPGZ loop.

To the command-line! I open Terminal and type the blissfully human-readable command to unzip the archive:

unzip archive.zip

I receive for my troubles a list of all the files in the archive…as they are skipped. Each carries with it an error:

skipping: file1.pdf  need PK compat. v4.5 (can do v2.1)
skipping: file2.pdf  need PK compat. v4.5 (can do v2.1)
skipping: file3.pdf  need PK compat. v4.5 (can do v2.1)

As it turns out, the well-meaning sender — through no fault of their own — has compressed the archive using 7-Zip, a popular Windows decompression engine, and, unfortunately, the built-in Mac OS X ZIP engine cannot unarchive the binary.

What’s needed here is p7zip, a port for POSIX systems like Unix. You can install it any number of ways (such as a direct download) but I prefer Homebrew:

brew install p7zip

Once installed the command to unarchive is:

7za x archive.zip

Not intuitive, I know, but when has Windows ever been accused of being intuitive?