92

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?

1
  • 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). Sep 24, 2019 at 17:11

5 Answers 5

116

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 /?.

7
  • 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
    Jan 14, 2010 at 18:49
  • 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
    Jan 14, 2010 at 18:57
  • 3
    7z 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. Jan 14, 2010 at 19:06
  • that worked, thanks again for taking the time to point that out: imagebin.ca/img/WhLSe0Sw.png
    – duhaas
    Jan 14, 2010 at 19:07
  • 1
    actually, it IS shown, if you type just 7z (minus the /?).
    – Molly7244
    Jan 15, 2010 at 2:54
19

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.

6

For p7zip:

7za e file.7z
1
  • perfect answer!!! +1 :) Nov 12, 2019 at 4:27
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
1

Without 7-zip powershell v3+ can extract a zip file:

Expand-Archive "Source" "Destination"
1
  • 1
    Powershell 5.1 can only extract .zips. e.g. for .gz "Expand-Archive : .gz is not a supported archive file format. .zip is the only supported archive file format."
    – timB33
    Dec 18, 2020 at 8:26

You must log in to answer this question.

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