7-Zip and unzipping from command line

49

16

I am looking to use the command line 7-Zip to unzip a folder.

I have a file, say example.zip and want to unzip the contents of the file into a folder called example.

What are the commands I need to do this?

duhaas

Posted 2010-01-14T18:34:05.750

Reputation: 613

also FYI there is usually a distro package from their official repo. there is also the direct source which is from sourceforge (source and binary). – Trevor Boyd Smith – 2019-09-24T17:11:33.563

Answers

64

7z x example.zip -oexample

Usage: 7z <command> [<switches>...] <archive_name> [<file_names>...]
       [<@listfiles...>]

<Commands>
...
  x: eXtract files with full paths
<Switches>
...
  -o{Directory}: set Output directory

Edit:

7z x *.zip -o*

extracts all *.zip archives to subfolders with names of these archives.

Strangely, I had to go to the full help file to find this example; it isn't shown for 7z /?.

Anonymous

Posted 2010-01-14T18:34:05.750

Reputation: 1 214

Got my vote just by mentioning 7z x *.zip -o* – рüффп – 2017-05-16T15:47:16.287

@Molly7244 in fact in the help you mention, there's no example with -o* using that wildcard in that place is not always supported by all programs. – рüффп – 2017-05-16T15:50:27.447

good lord, i'm an idiot. thanks much, appreciate the time to point out i should of paid more attention to the manual LOL, thanks again – duhaas – 2010-01-14T18:49:01.023

actually, that isnt creating a folder based on name of file:

7za x -o"J:\IMC11N E\Batch\LehmanPoint\Reports" "993002005 S.20091228.zip" – duhaas – 2010-01-14T18:57:25.577

17z x extracts with full paths; if you want to extract to current directory (ignore path info in the archive) use 7z e. i find both handy at different times. – quack quixote – 2010-01-14T19:06:24.717

that worked, thanks again for taking the time to point that out:

http://imagebin.ca/img/WhLSe0Sw.png

– duhaas – 2010-01-14T19:07:37.240

actually, it IS shown, if you type just 7z (minus the /?). – None – 2010-01-15T02:54:18.787

11

The syntax would be: 7z x <path to>\duane.zip -oc:\duane

This will extract the content of the archive duane.zip to the folder c:\duane with full paths.

Note: There is NO space between the switch -o and the destination folder. If that folder does not exist, it will be created automatically.

Molly7244

Posted 2010-01-14T18:34:05.750

Reputation:

4

For p7zip:

7za e file.7z

Maciek Sawicki

Posted 2010-01-14T18:34:05.750

Reputation: 1 072

perfect answer!!! +1 :) – SagarPPanchal – 2019-11-12T04:27:32.933

3

Recursively extract a single file, or a selective set of files from an archive into the current folder:

7za.exe e art.archive -ir!*Art.jpg

Mitch

Posted 2010-01-14T18:34:05.750

Reputation: 31