How can I extract multiple 7z files in folder at once in Ubuntu?
Asked Answered
A

11

32

How can I extract about 900 7z files which are all located in the same folder (all have only one file inside) without doing it one by one?

I am using Ubuntu 10.10. All files are located in /home/username/folder1/folder2.

Alessandraalessandria answered 25/11, 2010 at 3:45 Comment(0)
P
20
for arc in *.7z
do
  7zwhatever "$arc"
done
Premonitory answered 25/11, 2010 at 3:46 Comment(0)
M
50
7za -y x "*.7z" 

The above code worked for me

Madrid answered 7/9, 2016 at 11:54 Comment(3)
Quotes were the needed component I was missing. It didn't want to work without them.Keen
On Fedora 38 I had to comment out the asterisk, \*.7zFootless
This will extract all those zips into one subfolder of the current directory, overwriting already existing files without asking (the -y switch). If you have multiple files in those zips, you may want to unpack each zip into a separate subfolder. See Franck Dernoncourt's answer for that.Inherited
P
20
for arc in *.7z
do
  7zwhatever "$arc"
done
Premonitory answered 25/11, 2010 at 3:46 Comment(0)
L
11

Using parallel is rather convenient way with total progress meter for free ;)

ls *.7z | parallel -j+0 --eta '7z x {} >/dev/null'
Leaven answered 21/7, 2013 at 10:9 Comment(0)
R
10

7z x "*.7z" this worked for me in ubuntu

Ryswick answered 17/5, 2018 at 16:55 Comment(3)
Maybe you explain a little bit more what this line does, for example by citing the manpage. This may help other users with the same issue to better understand how this solves the problem.Drumm
Practically the same as the current top answer (posted in 2016), only doesn't have the -y flag (confirm all). Has Ubuntu had a package supplying the 7z command?Footless
Ubuntu has both p7zip, which is an old downstream fork of 7zip for Linux, and 7zip, which is the official upstream version now that they have official Linux support. If you install p7zip, the command is 7z. If you use the official 7zip, the command is 7zz.Sauder
R
7
for f in *.7z
do
    7zr e "$f" &
done

This will extract all .7z files if they're 7z format to the current directory, without waiting for completion.

Your computer could be owned. You have been warned!

Rally answered 25/11, 2010 at 3:59 Comment(1)
If you have 900 files then yeah, that will be pain.Premonitory
M
7

If you wish to extract multiple 7zip archives to folders with the same names in Linux, you can use:

for archive in *.7z; do 7z x -o"`basename \"$archive\" .7z`" "$archive"; done

For example, if you have two 7zip archives a.7z and b.7z, it will create two folders a and b, and uncompress a.7z into folder a and b.7z into folder b.

The above command comes from this answer on superuser by user Vojtech.

Mannose answered 4/6, 2018 at 1:36 Comment(0)
C
5

You do not need to overcomplicate things. To extract a 7-Zip archive split to multiply parts use the following command:

7z x archive.7zip.0

7-Zip will notice you that you have a multi-volume archive and it unpacks everything.

Cellobiose answered 23/3, 2020 at 1:39 Comment(1)
this worked great. also I used 7z x archive.7zip.00* and it put back together the two .001 and .002 files.Sendal
L
5

Probably the simplest approach is below

 ls | xargs -n1 7z x 
Lamia answered 22/12, 2020 at 5:11 Comment(0)
A
0

in adition to using a for loop

you can also use find in combination with the exec argument or xargs

Attract answered 25/11, 2010 at 3:48 Comment(0)
F
0

Another example with -aos parameter.

# ls Environment-voice-20180629-20180705-20230706024500.zip Environment-voice-20180729-20180802-20230706050000.zip | xargs -n1 7za x -aos '-xr!/http*'

7-Zip (a) [64] 16.02 : Copyright (c) 1999-2016 Igor Pavlov : 2016-05-21
p7zip Version 16.02 (locale=C.UTF-8,Utf16=on,HugeFiles=on,64 bits,16 CPUs Intel(R) Xeon(R) Platinum 8272CL CPU @ 2.60GHz (50657),ASM,AES-NI)

Scanning the drive for archives:
1 file, 2928050140 bytes (2793 MiB)

Extracting archive: Environment-voice-20180629-20180705-20230706024500.zip
--
Path = Environment-voice-20180629-20180705-20230706024500.zip
Type = zip
Physical Size = 2928050140
64-bit = +

Everything is Ok

Files: 631108
Size:       2664870996
Compressed: 2928050140

7-Zip (a) [64] 16.02 : Copyright (c) 1999-2016 Igor Pavlov : 2016-05-21
p7zip Version 16.02 (locale=C.UTF-8,Utf16=on,HugeFiles=on,64 bits,16 CPUs Intel(R) Xeon(R) Platinum 8272CL CPU @ 2.60GHz (50657),ASM,AES-NI)

Scanning the drive for archives:
1 file, 2387436055 bytes (2277 MiB)

Extracting archive: Environment-voice-20180729-20180802-20230706050000.zip
--
Path = Environment-voice-20180729-20180802-20230706050000.zip
Type = zip
Physical Size = 2387436055
64-bit = +

Everything is Ok

Files: 505001
Size:       2177832150
Compressed: 2387436055


Frey answered 20/7, 2023 at 6:24 Comment(0)
I
-2

The simplest way is unzip '*.zip'.

Make sure you have the ' marks.

Ingra answered 3/2, 2012 at 19:10 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.