-o (set Output directory) switch

Specifies a destination directory where files are to be extracted.

This switch can be used only with extraction commands.

Syntax

-o{dir_path}
{dir_path}
This is the destination directory path. It is not necessary to end the path with a path separator (backslash in Windows). If you include an asterisk (*) in {dir_path}, 7-Zip will replace the asterisk with the archive name in the path.

In Linux, you can use -spod switch to disable replacing asterisk (*) in {dir_path}.

-spo (set Output directory mode) switch

Specifies the path generation mode for the output directory for archive extraction. The output directory path is generated from the path specified in the -o{dir_path} switch and the name of the archive being unpacked.

Syntax

-spo[d | c | r]
Switch Description
-spod for Linux/Posix/macOS: -o{dir_path} specifies the direct path to the output directory. The asterisk (*) character in {dir_path} will not be replaced by the archive name.
-spoc 7-Zip will concatenate the path specified in -o{dir_path} with the archive name to form the final path to the output directory.
-spor 7-Zip will replace asterisk (*) character in the path specified in the -o{dir_path} with the archive name. This is the default option.

Examples

7z x "-oc:\Doc" archive.zip

extracts all files from the archive.zip archive to the c:\Doc directory.

7z x "-o*" "*.zip"
or
7z x -spoc "*.zip"

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

7z x -spoc "-oname1\name2" "*.zip"

extracts all *.zip archives to name1\name2\* subfolders. 7-Zip will concatenate name1\name2\ with the archive name to form the final path to the output directory.

7z x -spod "-oname1/long*name" archive.zip 

For Linux/Posix/macOS: it extracts archive.zip archives to name1/long*name directory. In that case 7-Zip doesn't replace the asterisk (*) character with the archive name.

Commands that can be used with this switch

e (Extract), x (Extract with full paths)