Copy Empty Subdirectories with MS-DOS XCOPY

This article explains how to use the MS-DOS 6.22 XCOPY utility to duplicate complete directory structures, including empty folders. It identifies the exact command-line switch required to preserve empty subdirectories during file transfer and provides practical syntax examples for immediate use.

The parameter that causes the MS-DOS 6.22 XCOPY utility to copy empty subdirectories is the /E switch.

In MS-DOS 6.22, the standard /S switch instructs XCOPY to copy directories and subdirectories, but it automatically skips any directories that do not contain files. To force the utility to create and preserve empty folders at the destination, the /E switch must be used in conjunction with the /S switch.

Command Syntax

To copy all files, subdirectories, and empty subdirectories from a source to a destination, use the following syntax:

XCOPY [source] [destination] /S /E

Example Usage

To copy the entire contents of C:\DATA to D:\BACKUP while retaining every folder, whether empty or populated, enter:

XCOPY C:\DATA D:\BACKUP /S /E

Parameter Breakdown

  • /S: Copies directories and subdirectories, excluding empty ones.
  • /E: Copies any subdirectories, even if they are empty. In MS-DOS 6.22, this switch must be accompanied by the /S parameter to function correctly.