MacOS: Compressing files with password in Mac OSX

Operating System, Technology


I want to compress all files in a directory and protect the zip file with password.


We can do it without installing third party software on Mac OSX like 7zip, iZip, etc.

Step 1: Prepare all files in 1 directory

Step 2: Open Mac terminal and Run ‘zip’ command on mac terminal

Go to the path which contains directory / files. In this case, I want to compress a directory inside: /Users/rajadavid/Desktop/

Then run this command on mac terminal:
zip -erj [filename].zip [directory_to_compress]

-e is to encrypt all files using password;
-r perform compression recursively to all files;
-j remove all internal directory. So the zip file will not store the full path (relative to the current directory).


 zip -erj /Users/rajadavid/Desktop/compress 

Step 3: Type the password in terminal twice

The compressed file with password protected will be available in: /Users/rajadavid/Desktop/

Further reading:


Leave a Reply

Your email address will not be published. Required fields are marked *