Introduction
For several years, I've used the 7-Zip command line interface, 7z.exe
for my daily backup needs. Continuing as I did long ago with its predecessor, WizZip, I constructed a batch file to automate regularly repeated backup chores, such as making backups of source code and program output directories. Today, I decided that I needed a companion script to restore files from an archive
In the process, I decided to put an end to my regular (and frequent) forays into the online help file that comes with the graphical user interface, 7zFM.exe
, by supplementing the help provided by 7z.exe
when you run it without parameters. Soon after I started using 7Zip regularly, I saved that output into a text file, which I put into a handy directory where I keep files for the command line system utilities that I use regularly, but not enough to have committed their command line arguments to memory. To ensure that I always have access to it,, even when I work on site, that directory is mirrored to the OneDrive directory associated with the Microsoft account that I use for work.
Background
As is the case with most system utilities, the help text generated when the utility is run without arguments is great if you know the minutiae pretty well, and just need a refresher from time to time, but it falls short as a true reference page. Thankfully, it usually needs only a few additions to make it vastly more useful as a true freestanding help document.
Using the code
Without further ado, following is my improved help.
Manual Page for 7z.exe, the 7-Zip Command Line Interface
7-Zip [64] 16.04 : Copyright (c) 1999-2016 Igor Pavlov : 2016-10-04
Usage: 7z<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)
h : Calculate hash values for files
i : Show information about supported formats
l : List contents of archive
rn : Rename files in archive
t : Test integrity of archive
u : Update files to archive
x : eXtract files with full paths
<switches>
-- : Stop switches parsing
-ai[r[-|0]]{@listfile|!wildcard} : Include archives
r = Modify as indicated for freestanding R switch. (See below.)
@ = Filespec is the name of a list file.
! = Filespec is a glob.
-ax[r[-|0]]{@listfile|!wildcard} : eXclude archives
-ao{a|s|t|u} : set Overwrite mode
a = All (unconditional)
s = Skip existing files
t = Rename existing file, e. g., if name.txt exists, rename it name_1.txt
u = Rename extracted file, e. g., if name.txt exists, extract as name_1.txt
-an : disable archive_name field
-bb[0-3] : set output log level
-bd : disable progress indicator
-bs{o|e|p}{0|1|2} : set output stream for output/error/progress line (See 7zFM help file.)
-bt : show execution time statistics
-i[r[-|0]]{@listfile|!wildcard} : Include filenames
r = Modify as indicated for freestanding R switch. (See below.)
@ = Filespec is the name of a list file.
! = Filespec is a glob.
-m{Parameters} : set compression Method
-mmt[N] : set number of CPU threads
-o{Directory} : set Output directory
-p{Password} : set Password
-r[-|0] : Recurse subdirectories (The 7zFM help file asserts that this works with E and X commands.
Though it may do so, it doesn't behave as I would expect.)
bare = Enable recursion, presumably w/o respect to glob (wild card mask)
- (e. g., -r-) = Disable recursion
0 (e. g., -r0) = Recurse subdirectories, respecting the glob
-sa{a|e|s} : set Archive name mode
a = Always append extension per specified archive type (requires -t switch)
e = Use name exactly as specified on command line
s = Use extension if supplied, else add per specified archive type (requires -t switch)
-scc{UTF-8|WIN|DOS} : set charset for for console input/output
-scs{UTF-8|UTF-16LE|UTF-16BE|WIN|DOS|{id}} : set charset for list files
-scrc[CRC32|CRC64|SHA1|SHA256|*] : set hash function for x, e, h commands
-sdel : delete files after compression
-seml[.] : send archive by email
-sfx[{name}] : Create SFX archive
-si[{name}] : read data from stdin
-slp : set Large Pages mode
-slt : show technical information for l (List) command
-snh : store hard links as links
-snl : store symbolic links as links
-sni : store NT security information
-sns[-] : store NTFS alternate streams
-so : write data to stdout
-spd : disable wildcard matching for file names
-spe : eliminate duplication of root folder for extract command
-spf : use fully qualified file paths
-ssc[-] : set sensitive case mode
-ssw : compress shared files
-stl : set archive timestamp from the most recently modified file
-stm{HexMask} : set CPU thread affinity mask (hexadecimal number)
-stx{Type} : exclude archive type
-t{Type} : Set type of archive (See 7zFM help file.)
-u[-][p#][q#][r#][x#][y#][z#][!newArchiveName] : Update options (See 7zFM help file.)
-v{Size}[b|k|m|g] : Create volumes (See 7zFM help file.)
-w[{path}] : assign Work directory. Empty path means a temporary directory
-x[r[-|0]]{@listfile|!wildcard} : eXclude filenames (See 7zFM help file.)
-y : assume Yes on all queries
</switches></commands></file_names></archive_name></switches>
Points of Interest
Of particular interest are the additions covering the R and I switches, especially my observation that the freestanding R switch seems not to work as advertised. Thankfully, in combination with the I switch, it works just fine.
For your convenience, I put a copy of the original help file in the article download. Though the file is quite small, it's a ZIP, since CP doesn't support text files.
History
On Saturday, 29 December 2018, the article was submitted for publication.