thafaker.crabdance.com

Welcome to my vintage Webserver with ftp; Files and Stuff for ms-dos, c64, amiga, howtos, classic mac

CMD add File to ZIP

Date: [26th Sep 2024]
Categories: [linux], [howto]

Sometimes it’s easy to delete a ZIP file and create a new one – say you’ve forgotten to include a file. Just drag it into the folder to be ZIPped up and start again.

However, the clever little ZIP command line tool has a built-in ability to simply add a file to an existing archive without us having to do any manual grunt work. That can come in handy when we no longer have access to existing unZIPped content. This works on all UNICES, also macOS Terminal.

Here’s how it works:

zip /path/to/archive.zip addfile1 addfile2 addfile2

We can even add entire directories this way too, like so:

zip -r /path/to/archive.zip directory/*

This will recursively add all files (indulging hidden and annoying ones) to our file.

Note that ZIP accomplishes this by temporarily extracting all files before creating a new archive for is (while deleting our original file). So in essence, the tools is doing what we’d do manually, just more conveniently and in the background without bothering us.