Robert Cardona
Robert Cardona

Reputation: 1138

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

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.

Upvotes: 32

Views: 67304

Answers (11)

Nash A
Nash A

Reputation: 91

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


Upvotes: 0

Anatolii Shuba
Anatolii Shuba

Reputation: 6085

Probably the simplest approach is below

 ls | xargs -n1 7z x 

Upvotes: 5

zappee
zappee

Reputation: 22668

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.

Upvotes: 6

Franck Dernoncourt
Franck Dernoncourt

Reputation: 83167

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.

Upvotes: 7

pzyxian
pzyxian

Reputation: 109

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

Upvotes: 10

Santosh Pillai
Santosh Pillai

Reputation: 1391

7za -y x "*.7z" 

The above code worked for me

Upvotes: 52

Ruslan Prakapchuk
Ruslan Prakapchuk

Reputation: 614

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

ls *.7z | parallel -j+0 --eta '7z x {} >/dev/null'

Upvotes: 11

M Tarmiz
M Tarmiz

Reputation: 5

The simplest way is unzip '*.zip'.

Make sure you have the ' marks.

Upvotes: -2

Matt Joiner
Matt Joiner

Reputation: 118500

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!

Upvotes: 7

hhafez
hhafez

Reputation: 39750

in adition to using a for loop

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

Upvotes: 0

Ignacio Vazquez-Abrams
Ignacio Vazquez-Abrams

Reputation: 798606

for arc in *.7z
do
  7zwhatever "$arc"
done

Upvotes: 20

Related Questions