Software >> Applications >> Zip >> 7-zip >> How to use 7-zip (7z.exe) in a command line

 

To archive

Syntax:

7z.exe a –tzip <archivefilepath> <filestoarchivepath>
7z.exe a –t7z <archivefilepath> <filestoarchivepath>
7z.exe a –tgzip <archivefilepath> <filestoarchivepath>
 
Eg.
7z.exe a –tzip c:\data\abc.zip c:\data\logs\*.*
7z.exe a –tzip c:\data\abc.7z c:\data\logs\*.*
7z.exe a –tzip c:\data\abc.gz c:\data\logs\*.*

To Extract

Syntax

7z.exe e <archivefilepath>
7z.exe e <archivefilepath> -o<targetoutputdir>

Example

7z.exe e c:\data\abc.zip
7z.exe e c:\data\abc.7z
7z.exe e c:\data\abc.zip -oc:\data\logs
7z.exe e c:\data\abc.7z -oc:\data\logs

To List

Syntax

7z.exe l <archivefilepath>

Eg.

7z.exe l c:\data\abc.zip