Programming Field

Expand (File extraction utility) - DOS/Command Prompt Reference

[MS-DOS 5.0 or later/Windows XP? or later] Extracts (unzips) files compressed in a specific format.

* Files that can be expanded with the Expand program are limited to those in LZ77 format (with the extension ‘_’ (underscore) and the file content starting with ‘SZDD’) or in cab file format (Expand.exe included with Windows XP and later versions or with Windows OPK/AIK supports cab file format). To compress in LZ77 format, you need to use the compress.exe included with old MS-DOS or a compatible program (such as MsCompress).

Syntax

expand[.exe] [-R] <source> <destination>
expand[.exe] -R <source> [<destination>]
expand[.exe] -I <source> [<destination>]
expand[.exe] -D <cab-file> [-F:<file>]
expand[.exe] <cab-file> -F:<file> <destination>

Options

[-R] <source> <destination>

Expands the compressed file specified by <source> to <destination>. Multiple files can be specified in <source> separated by spaces (wildcards are also allowed), and if <source> is a single file, <destination> can also be a filename (it will be expanded to that file). However, if multiple files are specified, <destination> must be a directory, with the last item in the space-separated list considered as the destination.

Note that when specifying a file with the extension ending with ‘_’ (LZ77 format) in <source> without the -R option and specifying a directory name in <destination>, whether the expanded file name retains the ‘_’ part based on the file name of <source> depends on the version of the Expand program (not confirmed). To ensure proper restoration, please specify the ‘-R’ option.

[Expand supporting cab file] If a single CAB file is specified in <source>, the expansion will not occur, and a message prompting the use of the -F option will be displayed. However, if multiple CAB files are specified in <source>, the expansion of all files will take place in the directory specified in <destination>.

-R <source> [<destination>]

Expands the compressed file specified by <source>. If the -R option is specified, <destination> can only be a directory. However, other than that, the specification of <source> and <destination> follows the same method as the first specified method (see above).

When using the -R option to expand a file with the extension ending with ‘_’ (LZ77 format), if the filename part is omitted in <destination> (either <destination> is a directory or not specified), the expanded filename will be restored based on the file name of <source> by reconstructing the ‘_’ part. The characters that go into the ‘_’ part are determined by the information contained in the compressed file (if no information is included, the ‘_’ character will simply be removed). Additionally, if <destination> is omitted, the output destination will be the same directory as the compressed file.

* The information for the ‘_’ part of the filename (extension) needs to be specified as an option during file compression (using the ‘-R’ option in the Compress program). It's worth noting that this specification feature is not implemented in the compatible program MsCompress (as of August 2015). Additionally, only the last character of the extension will be restored.

-I <source> [<destination>] [Windows Vista? or later] Similar to when the -R option is specified, but it ignores the directory structure of the compressed files (expands all files to the same directory without creating subdirectories).
-D <cab-file> [-F:<file-list>] [Windows XP? or later] Displays a list of files contained in <cab-file> and then exits without performing extraction. <cab-file> can include multiple CAB files as well as LZ77 format files (files with the extension ending with ‘_’) (wildcards are allowed). When the ‘-F:<file>’ option is specified, it only outputs files that match the specified <file> (wildcards are allowed).
<cab-file> -F:<file-list> <destination>

[Windows XP? or later] It expands the files contained in <cab-file>. <cab-file> can include multiple CAB files as well as LZ77 format files (files with the extension ending with ‘_’) (wildcards are allowed). In this pattern, the -F option is mandatory, and <destination> must always specify a directory.

Note that even when expanding LZ77 format files with this option, the conversion of the ‘_’ at the end of the extension is not performed.

* The format without the -F option is the same as the first format, but as mentioned above, when specifying a single CAB file, the -F option becomes necessary.

[MS-DOS version] If you omit -R and <source> or <destination> without specifying, a prompt will be displayed to request their contents.

Details

The Expand program is primarily used to extract specific files, such as retrieving missing files, from compressed files in Windows setups. While the MS-DOS version supports only LZ77 format, the version provided from Windows XP onwards(?) adds support for cab files in addition to LZ77 format files (allowing the expansion of LZ77 format files as well).

Note that there is no program provided (excluding the old MS-DOS Compress.exe) specifically for creating compressed files. However, cab files created using common compression programs can be used (expanded) with Expand.

Samples

Sample 1

expand -R D:\SETUP\APP.EX_ C:\PROGRAM

(If C:\PROGRAM is a directory), the compressed file ‘APP.EX_’ will be expanded in C:\PROGRAM. If ‘APP.EX_’ had the information ‘the extension ends with E’, it would be expanded as ‘C:\PROGRAM\APP.EXE’.

Sample 2

expand R:\DATA1.CAB R:\DATA2.CAB -F:*.txt D:\Files

[Windows XP? or later] (If D:\Files is a directory), all files with the extension ‘txt’ contained in the compressed files ‘DATA1.CAB’ and ‘DATA2.CAB’ will be expanded in D:\Files.