Mac OS X: How to create an encrypted Zip archive of a folder

Updated: 1/17/12

OK, found an even better, GUI based way to do this for Free.  Check out Keka opensource.  give it a password, drag, drop, done!



Mac OS X: How to create an encrypted Zip archive of a folder

Posted by Pierre Igot in: Macintosh
March 31st, 2010 • 10:08 am

Mac OS X’s user interface comes with a built-in facility for creating Zip archives, in the form of a command called “Compress…” in the Finder’s “File” menu or in the contextual action menu. (I believe the command used to be called “Archive…” in versions of Mac OS X prior to Mac OS X 10.5, also known as Snow Leopard.)

It works fine for creating simple Zip archives that can then be shared with other Mac or PC users.

But this facility provides no option to create a password-protected or encrypted Zip archive.

I know that you can purchase a third-party tool such as StuffIt Deluxe that provides such an option. But this third-party product is too expensive and feature-rich for my tastes. In addition, the StuffIt product family does not have a very good history under Mac OS X. Its interface is very lousy (especially for decompressing password-protected Zip archives, among other things) and there have been pretty significant bugs in the past.

The truth is that Mac OS X comes with its own feature for creating password-protected or encrypted Zip archives. It’s just that it’s not accessible in the graphical user interface (GUI). You have to use the command line interface.

As per usual in the CLI world, the most simple things are not obvious and if you bring up the man page in Terminal for the zip command, you will spend a fair bit of time figuring out exactly which options you need.

Since I went through this myself two days ago, I thought I would share the result of my investigations. As far as I can tell, in order to create a password-protected and encrypted archive of a folder, you need to type this in Terminal:

zip -ejr [name] [path to folder]

[name] is the name you want to give to the resulting archive file (without the “.zip” extension, which the zip command will add automatically).

And [path to folder] is the complete name of the folder with its full path. Instead of typing it, you can just type zip -ejr [name] followed by a space and then drag-and-drop the target folder onto the command line. Terminal will automatically insert the full path with escape characters if required.

For your information, the “e” option stands for “encryption,” the “j” for “junk the path” (otherwise the zip command will archive the complete folder hierarchy leading to your target folder, which you probably don’t want), and “r” stands for “recursive,” which will force the zip command to include the entire contents of the folder in the archive. (Otherwise it will only archive the folder itself without its contents, which is not exactly useful.)

Once you execute this command, Mac OS X will ask for the desired password (twice, for confirmation), and then create a Zip archive of your folder with your chosen name at the root level of your home folder. (If you want to specify a different location, you need to provide the full path instead of just the name.)

Et voilà.

It’s not fantastically user-friendly, but it’s far cheaper than StuffIt Deluxe, and at least it does not have a lousy GUI.

DISCLAIMER: I am not a CLI expert and there might be a better/more efficient way to do this. But this works for me.

This entry was posted by Pierre Igot on Wednesday, March 31st, 2010 at 10:08 am and is filed under Macintosh. You can follow any responses to this entry through the RSS 2.0 feed. Responses are currently closed, but you can trackback from your own site.



Comments are closed.

Very useful for creating a secure password ZIP file in the cloud (like saving to DropBox – even if they break into DropBox, they gotta get through the encrypted ZIP file).

BTW – the default expander for MAC doesn’t work for expanding this file, you need Stuffit Expander to get to it.

Author: Joel Vincent

Growth Hacker and wine lover

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.