7-Zip Command Line Usage and Examples

{lang: 'ar'}

7-Zip is a free file archiver utility available under the terms of GNU Lesser General Public License. It works in Windows 98/ME/NT/2000/XP/Vista /Windows 7 and a port of the command line version is available for Linux and other *ix Operating System’s. 7-Zip is available either as a graphical tool or a command line one. There is also a 64-bit version to support Windows XP 64 bit Operating System and also features integration with Windows Shell.

This article outlines 7-Zip command line usage with simple examples.

Getting Started

  • Download 7-Zip Command Line Version from here
  • Unzip the files
  • Open cmd prompt and change directories to the extracted 7-zip files
  • Enter 7za at the prompt

[important title="usage"]

An extract of the usage is shown below

C:\software\7za920>7za

7-Zip (A) 9.20  Copyright (c) 1999-2010 Igor Pavlov  2010-11-18

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

<Commands>
a: Add files to archive
b: Benchmark
d: Delete files from archive
e: Extract files from archive (without using directory names)
l: List contents of archive
t: Test integrity of archive
u: Update files to archive
x: eXtract files with full paths
<Switches>
-ai[r[-|0]]{@listfile|!wildcard}: Include archives

[/important]

Usage Examples

Archive files

Archive two files license.txt and readme.txt to an archive called text.7z

[important title="archive usage"]
C:\software\7za920>7za a text.7z license.txt readme.txt

7-Zip (A) 9.20  Copyright (c) 1999-2010 Igor Pavlov  2010-11-18
Scanning

Creating archive text.7z

Compressing  license.txt
Compressing  readme.txt

Everything is Ok

C:\software\7za920>

[/important]

In the above example,

a – add files to archive, text.7z is the archive file name, and license.txt and readme.txt are the files to be archived

List Archive Files

To list archived files, use[highlight]7za l <arhive_file>.7z[/highlight]

[important title="List archived files"]
C:\software\7za920>7za l text.7z

7-Zip (A) 9.20  Copyright (c) 1999-2010 Igor Pavlov  2010-11-18

Listing archive: text.7z


Path = text.7z
Type = 7z
Method = LZMA
Solid = +
Blocks = 1
Physical Size = 1284
Headers Size = 180

Date      Time    Attr         Size   Compressed  Name
——————- —– ———— ————  ———————
2010-03-13 03:06:33 ….A         1162         1104  license.txt
2010-11-18 11:09:09 ….A         1254               readme.txt
——————- —– ———— ————  ———————
2416         1104  2 files, 0 folders

C:\software\7za920>

[/important]

Update Files to Archive

Add access.txt to the created archive file, text.7z

[important title="Update Archive"]

C:\software\7za920>7za u text.7z access.txt

7-Zip (A) 9.20  Copyright (c) 1999-2010 Igor Pavlov  2010-11-18

Scanning

Updating archive text.7z

Everything is Ok

C:\software\7za920>

[/important]

Test Archive Integrity as follows:[highlight]7za t text.7z[/highlight]

[important title="Test Archive Integrity"]

C:\software\7za920>7za t text.7z

7-Zip (A) 9.20  Copyright (c) 1999-2010 Igor Pavlov  2010-11-18

Processing archive: text.7z

Testing     license.txt
Testing     readme.txt
Testing     access.txt

Everything is Ok

Files: 3
Size:       2416
Compressed: 1308

C:\software\7za920>

[/important]

Delete Archive

To delete an archive, use as follows: [highlight]7za d text.7z[/highlight]

[important title="Delete Archive Files"]
C:\software\7za920>7za d text.7z

7-Zip (A) 9.20  Copyright (c) 1999-2010 Igor Pavlov  2010-11-18

Updating archive text.7z

Everything is Ok

Split Large File into smaller Files

Use the -v switch to split a large file into smaller ones. Let us assume that you have a limitation of 10MB to email files and the archive file size that you have is 11MB. use the -v switch to split the file into two files

Usage

C:\software\7-zip>7z a abc.7z text.7z -v9M -v2M

7-Zip [64] 9.20 Copyright (c) 1999-2010 Igor Pavlov 2010-11-18
Scanning

Creating archive abc.7z

Compressing text.7z

Everything is Ok

In the above example

- a stands for archive
- abc.7z is the file name you plan to split the archive into
- text.7z is the large file that you wish to split
-v is the volume, followed by the volume size

here 11MB size is split into two files 9M and 2M respectively

when the files are split, 7zip will use the following naming conventions

abc.7z.001
abc.7z.002 . . . and so on

 

Comments

  1. Anonymous says:

    When using 7-zip from the cmd line:

    Does anyone know what that “percent value” is?
    It just says “11%” with NO explanation of any kind.

    That 1 file got an 11% compression ratio?
    That 1 file is 11% done?
    11% of the “time to complete” is done?

    Why just say “11%”???? Put the *WORD* next to it.

    And why are all the values being ERASED? I want to see the compression ratios… without
    having to sit here a stair at the screen for 2 hours.

Trackbacks

  1. [...] archive utility. If you would like to use 7-Zip command line utility to split large files, click hereSelect all the files to be archivedRight-click > 7-Zip > Add to ArchiveEnter a name in the [...]

Page optimized by WP Minify WordPress Plugin