How To Zip A Folder On Mac Terminal

When you run the rm -R command on a folder, you’re telling Terminal to delete that folder, any files it contains, any sub-folders it contains, and any files or folders in those sub-folders, all. For zipping multiple files using Terminal, you can alternatively drag all the files you want into a folder to be zipped. (Let's call this folder foldername.) Type in 'cd.' Without quotes, drag foldername into the terminal, and press enter. Then, type in 'zip -r name.zip foldername' without quotes, and press enter. Zip -r archivename.zip foldertocompress. Unzip archivename.zip. If you want to make a zip without those invisible Mac resource files such as “MACOSX” or “.Filename” and.ds store files, use the “-X” option in the command so: zip -r -X archivename.zip foldertocompress. Zipping files through the Terminal can be helpful, especially if SSH is enabled on a remote Mac, because you can log in and zip files remotely. Zipping Files Cyber Monday deals: see all the best.

If you are a Mac user then guide below will let you know how you can create encrypted Zip file on Mac using Terminal commands and protect your sensitive data. So, it will minimize the damage to your data if someone get unauthorized access to your Mac.

Create Encrypted Zip Files on Mac

Find “Terminal” in Spotlight and select it to launch or you can navigate through “Finder” icon from the dock > “Applications” > “Utilities” > “Terminal”

Advertisement

Note: In terminal jump to the exact path where you have file or folder that you want to make password protected. In our case the folder exists on Desktop, so first we move to desktop through Terminal by typing command cd desktop and then we continue with the command to create protected zip file.

Create Password Protected Zip file from a Folder

Terminal command to Create password protected zip file

zip -e TW.zip TW

where:
zip -e = command name
TW.zip = zip file name, which we are going to create from TW folder
TW = original folder name

When we type this command and hit return, terminal will ask for the password and verification of password, provide that, and in result TW.zip file will be created on your current path.

Create Password Protected Zip from a File

If you want to protect a single file instead of folder use this command

zip -e TWDocument.zip TWDocument.jpg

where:
TWDocument.zip = protected file that we are going to create
TWDocument.jpg = file name with extension that we want to protect

Now, When we try to unzip created zip file, Archive Utility will prompt and ask to enter password to make the contents of zip file visible.

Mac Go To Folder

Zip

How To Zip A Folder On Mac Terminal File

Related Content