Tips to compress (Rar, Zip) files on Mac with Password protection

There are many available achiever app for Mac, but to me, all is like shit even the commercial one by slow working speed, high consumption of CPU and Memory, and limitation on processing the big files (over 2Gb).

In the following word, I will show you quick way to compress files into .Zip, .Rar with Password protection using command lines though Terminal Window.
Let’s started with the zip compression first.

STEPS TO ZIP A FILE AND FOLDER ON MAC WITH PASSWORD PROTECTION
Just open Terminal (Found under ), then enter the following command:

zip -er ~/directory/archive_name.zip ~/directory/files

If you can not find a directory of a specific file or folder on Mac, just drag and drop the folder and files into the Terminal windows. The following topic would help: How to find a file and folder location in MacOS system?

For example, i am going to compress the “rar” folder under /Users/Macdrug/Downloads/rar to a zip file named applehint.zip into the “Downloads” folder:

zip -er /Users/Macdrug/Downloads/applehint.zip /Users/Macdrug/Downloads/rar


You need to fill the protection password and confirm it again.

HOW TO CREATE A RAR FILE ON MAC WITH PASSWORD PROTECTION?

  • Firstly, the we need to install the RarLab into the MacOS. Look at this easy instruction.

To compress a folder or file on Mac into a .Rar file with Password protection, use the following command line:

rar -p ~/directory/archive_name.rar ~/directory/files

For example, I am going to compress the “rarosx-5.7.0.tar.gz” (INPUT), and I want the output is “applehint.rar”, which is going to be created into a current folder (OUTPUT) named “Hint Apple” that I don’t know exactly the directory.

If you know exactly the Directory of the INPUT and OUTPUT, the following full command line can help to do all above processes by just an Enter button:

rar a -p /Users/Macdrug/Downloads/Hint\ Apple/applehient.rar /Users/Macdrug/Downloads/rar/untitled\ folder/rarosx-5.7.0.tar.gz