6

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?

creat0r
  • 71
  • 1
  • 1
  • 3
  • 2
    I’m voting to close this question because its not programming related may be better suited for https://webapps.stackexchange.com/ – Linda Lawton - DaImTo Jul 01 '21 at 07:24
  • I created two zip files named `fnård.zip` and `börk.zip` and tried your command. It worked fine on them. Perhaps the allegations that Scandinavian characters won't work come from an older system, or one where the file names were not correctly transferred (for example, I can imagine that a zip file with a Unicode name could end up looking mangled on Windows. This is a feature of the local filesystem's encoding support, not of `unzip`). – tripleee Jul 01 '21 at 07:30
  • While I've closed this as "unclear", because it isn't sufficiently explicit as to your requirements (e.g. it's missing *exactly* which files to include and exactly which ones to exclude), it's asked as a general computing task, rather than as a programming problem (which makes it off-topic here on Stack Overflow). If the question was more clear it *might* be able to be rewritten as a *programming* problem. – Makyen Jul 01 '21 at 13:49
  • 1
    I received a fantastic answer so obviously my questions wasn’t unclear. Also, I posted this question on other forums first, but since you programmers obviously didn’t want to help me on other forums, I was forced to come here. This is a programming problem since it was a issue that needed to be resolved with programming. I don’t understand the issue? Thanks to tripleee and M. Zhang for actually helping me instead of telling me to go away. I think a lot of people on the web can benefit from their answers and knowledge. – creat0r Jul 01 '21 at 20:08

1 Answers1

14

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. 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 "$archive" -o combined
done

Wrapping up, here is everything to run:

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

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

By the way, welcome to Stack Overflow.

M. Zhang
  • 750
  • 8
  • 18
  • 1
    Thanks for the answer. Using `unar `, after each zip file I obtained this prompt: `Books-20221229T212225Z-002.zip: Zip "combined/Books" already exists. (r)ename to "Books-1", (R)ename all, (o)verwrite, (O)verwrite all, (s)kip, (S)kip all, (q)uit?` I had to type `O` multiple times to it to work. Maybe you should consider updating your answer to deal with this situation. – f10w Dec 30 '22 at 10:26