Search code examples
macosfileterminalgoogle-drive-apizip

Merge/combine multiple downloaded ZIP-files from Google Drive on Mac


When downloading a large folder (>50 GB) from Google Drive it'll split the download up in multiple smaller ZIP-files (about 2 GB each) which makes the original master folder a nightmare to put together again with all the files in their correct subfolders.

How do I merge/combine multiple downloaded ZIP-files from Google Drive on Mac?

Here's an existing thread about this that I couldn't reply to since I'm new to stackoverflow: Combine the split zip files downloading from Google Drive

In this thread, they mention this command:

mkdir combined
unzip '*.zip' -d combined

However, how do I make this command only unzip and combine my specific ZIP-files in my Downloads-folder and not all ZIP files on my entire drive? The command doesn't seem to specify the Downloads-folder, which makes me worried that it'll unzip and combine all files on my entire drive. I have some ZIP files on my hard drive that I don't want to unzip. Also, someone mentions this command doesn't work with characters in other languages (like û, å, ä, ö) so how can I make it work for my Swedish file names?


Solution

  • That two lines you mentioned will only unzip all .zip files in your current directory, into a folder called combined. Here is what is does:

    • mkdir combined creates a new directory called combined.
    • unzip '*.zip' -d combined selects all files ending with .zip, and puts their contents into `combined.

    Both of the two lines only operates on the current directory (That's why it is called "current working directory" - most commands in the terminal will not try to climb over your entire drive).

    Since you mentioned that your ZIP files are in the Downloads folder, you should first change your current directory, using the cd command like this:

    cd Downloads
    

    And you have mentioned non-ASCII file names. In this case, "The Unarchiver" works better. Apart from a graphic application, it has a command-line utility called unar. You can download it here or just brew install unar. For unar, it cannot take multiple files at once (afaik), so you have to construct a loop like this:

    for archive in *.zip
    do
    unar -f "$archive" -o combined
    done
    

    Wrapping up, here is everything to run:

    cd Downloads
    mkdir combined
    for archive in *.zip; do unar -f "$archive" -o combined; done
    

    And your files will all be unarchived into Downloads/combined.

    By the way, welcome to Stack Overflow.