Decompressing multiple files at once
I have more than 200 .zip files in one folder. I don't want to decompress those one by one. I want to extract those using single command or script. How to do that.
7 Answers
If you really want to uncompress them in parallel, you could do
for i in *zip; do unzip "$i" & doneThat however, will launch N processes for N .zip files and could be very heavy on your system. For a more controlled approach, launching only 10 parallel processes at a time, try this:
find . -name '*.zip' -print0 | xargs -0 -I {} -P 10 unzip {}To control the number of parallel processes launched, change -P to whatever you want. If you don't want recurse into subdirectories, do this instead:
find . -maxdepth 1 -name '*.zip' -print0 | xargs -0 -I {} -P 10 unzip {}Alternatively, you can install GNU parallel as suggested by @OleTange in the comments and run
parallel unzip ::: *zip 6 The GNU parallel command is well suited to this type of thing. After:
$ sudo apt-get install parallelThen
ls *.zip | parallel unzipThis will use as many cores as you have, keeping each core busy with an unzip, until they are all done.
17You can use the following command :
First change directory in terminal to directory that contains .zip files :
cd /pathThen execute this command to unzip all .zip files :
for z in *.zip; do unzip "$z"; done If you have many .zip files in your folder and you want to decompress all of them then open terminal and go to your folder using:
cd <path_to_folder>Now use this command to decompress all your .zip file:
ls *.zip | xargs -n1 unzip 5 You can use find with -exec like so,
find . -name "*.zip" -exec unzip {} \;This will work if the file has a space in the name.
A non terminal method.
Just select the zip files, right click on one and choose extract here. You can select all or just a number of zip files at a time.
unzip \*.zip or unzip '*.zip'
The obvious unzip *.zip doesn't work, because the shell expands it to unzip foo.zip bar.zip ... and unzip interprets the first filename as the zip file, and the following filenames as files to extract from that zip file.
However, unzip is a bit unusual among Unix commands in that it does its own glob expansions. If the * is not expanded by the shell, unzip will do it, and intepret all the resulting filenames as zip files to be processed. So in this special case, one can get away without a for loop or xargs or the like.