MS-DOS 6.22 EXPAND Target Directory Processing

This article explains how the MS-DOS 6.22 EXPAND utility handles target directories during file decompression. In MS-DOS 6.22, EXPAND is used to unpack compressed installation files (often ending with an underscore, such as .EX_). Depending on whether a single file or multiple files are targeted, the utility evaluates destination arguments differently to determine whether the output path represents an existing directory, a new filename, or an invalid target.

Single File Expansion

When decompressing a single file using the syntax EXPAND source destination, the utility checks the destination argument to determine whether it is a directory or a file:

  • Existing Directory: If the destination path matches an existing directory (for example, EXPAND A:FORMAT.CO_ C:\DOS), EXPAND reads the original, uncompressed filename embedded inside the header of the source file and extracts it directly into that directory (resulting in C:\DOS\FORMAT.COM).
  • Trailing Backslash: Appending a backslash to the target (such as C:\TARGET\) explicitly indicates to the command that the destination is intended to be a directory. If the directory exists, the file is placed inside it using its original name.
  • Filename Output: If the destination does not end in a backslash and does not match an existing directory name, EXPAND assumes the target is a full file path and writes the uncompressed contents under that specified name (for example, EXPAND A:FORMAT.CO_ C:\TEMP\MYFORMAT.COM).

Multiple File Expansion

When providing multiple source files (using wildcards or multiple file arguments), the destination rules become stricter:

  • Mandatory Directory: The final parameter in a multi-file command must resolve to an existing directory.
  • Processing Behavior: For each matched file, EXPAND extracts the embedded original filename from the compressed header and writes each file into the specified target folder.
  • Error Handling: If multiple files are provided and the target is omitted, not recognized, or points to an invalid directory, EXPAND halts and returns a command-line error indicating that the destination must be a directory.

Directory Creation and Path Validation

  • No Automatic Directory Creation: The MS-DOS 6.22 EXPAND command cannot create directories. If a user targets a non-existent path expecting the utility to generate the folder tree, the command either misinterprets the path as a single target filename (during single-file operations) or fails with an error such as "Cannot create file" or "Path not found."
  • Drive and Relative Path Resolution: EXPAND honors standard DOS pathing conventions. Specifying only a drive letter (such as D:) targets the current working directory of that drive. Relative paths (such as ..\BACKUP) are evaluated relative to the current active directory of the current drive.