1. Home
  2. Mac OS X
  3. Add a file to an existing archive password protect it on mac

Add A File To An Existing Archive & Password Protect It On Mac [Tip]

Compressing files and creating archives in Mac is easily accomplished through the default utility, Archive, which compresses to a whole host of formats. Files can be compressed in command line as well via the Terminal, but having to compress files or folders through the command line is much more complicated and inconvenient, which is why it’s best to use the tool provided. If you aren’t a fan of the native utility for some reason, there are plenty of other apps that you can use instead. and if nothing else works for you, the Terminal really isn’t going anywhere. One advantage that Terminal holds in this regard, is that, in addition to being able to create archives, you can add a file to an existing one through a few simple commands. This can save you a lot of clutter; you can add files to a single archive as per your need, and not have a mess of archives in a folder or on your desktop.

Move the file you want to add to the archive to the same directory as the original ZIP file. For instance, if your zipped file is on the Desktop, move the file you want to add to the desktop as well. Remember that finding a folder path isn’t difficult; you can simply drag & drop a folder onto the Terminal and it’s path will be displayed. Moving forward, assuming that both the ZIP and the file you want to add to it are on the desktop, in Terminal, write cd ~/desktop/ and hit Enter (cd means change directory, and any path that follows tells the Terminal to move to that directory).

Think of a password to protect the file with, and enter the following command:

zip –P Password –qr name-of-zipped-file.zip add-to-archive.mp3

Remember to write your password instead of Password in the above command, and enter the name of the ZIP file instead of name-of-zipped-file.zip. Likewise, add-to-archive.mp3 should be replaced with the name of the file you actually want to add, complete with the file extension.

archive Terminal

Bear in mind that if you add a password to an otherwise unprotected archive, you will not be able to unarchive the other unprotected files in it. If you only want to add a file to an existing archive and forgo the whole password thing, skip the –P switch and write the command without it.

The command is useful if you’ve forgotten to add one file to an archive, or if you need to add it to a ZIP file you’ve received, but don’t want to go though the whole unarchiving process.

Leave a Reply

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

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