23

I don't think that I'm the only one with this problem, but unfortunately I wasn't able to find the proper answer between previously asked questions.

It is a very common procedure on torrent sites where the content is split in many small archives. Sometimes, those small indexed zip archives are containing another rar archives inside.

So, my question is: how to you handle this problem? How to you recursively unpack those files?

4

4 Answers 4

31

To do so, just press Ctrl+Alt+T on your keyboard to open Terminal. When it opens, run the command(s) below:

unzip '*.zip'

Also you can right click on the first file in the group, and choose Extract here, and that will also all the files in that group.

4
  • According to the manual unzip doesn't support split archives (see the first paragraph in the section “Bugs”). Dec 23, 2014 at 13:10
  • @DavidFoerster just tested it, and it works.
    – Mitch
    Dec 23, 2014 at 14:03
  • Ok, then the manual appears to be wrong. Good catch. Dec 23, 2014 at 14:38
  • @mitch in my case it doesnt work it sais "error while loading the zip file" but on windows the same directory on the same disk unzips with winrar, maybe you tried to unzip multiple but >separate< zip file simultanously? thats an other thing though.
    – papajo
    Oct 11, 2017 at 0:39
5

To unzip multiple files using a loop -

for z in *.zip; do unzip "$z"; done
3
  • @DavidFoerster The two methods are essentially the same. *.zip provides all the possible files ending with a zip extension which the loop unzips one by one. This is also why @Mitch has included single quotes in his answer to make it '*.zip', so that the the shell will not recognize it as a wild card character. Dec 23, 2014 at 17:08
  • 2
    This is actually a better method since you can specify a file name list instead of saying "all files in the directory". I.E. you want to extract a specific list of zip files one after the other in order, you could do, "for z in X Y Z T G; do unzip -o "$z.zip"; done" and it would do it in that order. This is the better answer imho. Aug 23, 2017 at 8:29
  • Okay, but what is unzip's problem? If I do for z in find **/subdir/*.zip; unzip -l "$z"; done it will list the files in the folders but it will also give me this error cannot find or open find, find.zip or find.ZIP.. But that's not in the output of find.
    – grofte
    Mar 29, 2021 at 18:08
1

How to unzip multiple files at once

...using parallel operations (one CPU core per process, with as many processes as you have cores), into output directories with the same names as the zip files:

This might look complicated, but it's beautiful and fast. It will unzip all top-level *.zip files in your current directory into folders of the same name as the zip file:

# Install `unar` (un-archive)
sudo apt update
sudo apt install unar

# Unzip all files
time find . -maxdepth 1 -type f -iname "*.zip" -print0 | xargs -0 -I{} -n 1 -P $(nproc) unar -f {}
  • unar is used instead of unzip because unar automatically puts the extracted output into a folder with the same name as the .zip file.
  • If you'd like to extract *.zip files in lower levels too, remove the -maxdepth 1 option.

References

  1. Unix & Linux: Unzip to a folder with the same name as the file (without the .zip extension)
  2. My answer on how to use xargs

See also

  1. My longer answer, based on the work above, where I extract one or many password-protected files in parallel using find, xargs, and unar -p my_password path/to/myfile.zip.
0

CTRL+ALT+T to open up a terminal

for f in $(ls | egrep zip); do
  unzip $f -vd UnzippedDirectory
done

This basically loops through all the zips you got in your current directory, and unzips each of them verbose (hence the -v flag) into a directory (-d flag)

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .