Extract only some specific folders from ZIP file in MacOS

Hi!


I have a 8Gb ZIP file with the backup of a Linux laptop that has to be repaired. While I wait, I'd like to copy my "projects" folder from this file to my Macbook to continue working on them. I don't want to extract the whole ZIP file, only the aforementioned "projects" and "docs" folders but I can't find a way of doing it. Both the compression utility from MacOS and The Unarchiver only allow to extract all the files. I don't want to do this to avoid polluting my HDD with thousands of files that I'll have to delete after uncompressing them, so I'd like to know if there's a way to do this. I know I could use the terminal and the unzip command but, seriously, why such a simple (and useful) operation is not supported natively by MacOS? Thanks in advance!

MacBook Pro 15″, macOS 12.0

Posted on Nov 3, 2021 7:14 AM

Reply
Question marked as Top-ranking reply

Posted on Nov 3, 2021 8:11 AM

I selected two folders (Foo and Foobar) on my Desktop and zipped them into Archiver.zip. I then unzipped the Foobar folder and its contents from the zip archive into a new folder named Foobar or any other arbitrary name using:


unzip Archive.zip "Foobar/*" -d Foobar


This writes all of the associated zipped Foobar folder contents into the designated Foobar folder. Note, beware of namespace collisions for the output folder designation. I copied the Archive.zip file into another desktop folder before executing the above syntax. Tested: macOS 11.6.1. I would expect this to work on Monterey too.


Reference: How to extract only a specific folder from a zipped archive to a given directory?


6 replies
Question marked as Top-ranking reply

Nov 3, 2021 8:11 AM in response to felipRR

I selected two folders (Foo and Foobar) on my Desktop and zipped them into Archiver.zip. I then unzipped the Foobar folder and its contents from the zip archive into a new folder named Foobar or any other arbitrary name using:


unzip Archive.zip "Foobar/*" -d Foobar


This writes all of the associated zipped Foobar folder contents into the designated Foobar folder. Note, beware of namespace collisions for the output folder designation. I copied the Archive.zip file into another desktop folder before executing the above syntax. Tested: macOS 11.6.1. I would expect this to work on Monterey too.


Reference: How to extract only a specific folder from a zipped archive to a given directory?


Nov 5, 2021 5:16 AM in response to felipRR

I was about to recommend The UnArchiver, but it does not seem to allow one to extract selectable content from within the zip archive, and extracts everything. So the time to market, so to speak, is to use the command line solution as I offered earlier.


You can check the Mac App Store by searching for unzip if you need a visual interface product, but probably not all give you piecemeal unzip capability.

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

Extract only some specific folders from ZIP file in MacOS

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.