How MS-DOS 6.22 Prevents COPY Overwrite Conflicts
MS-DOS 6.22 prevents accidental data loss during file operations by
enforcing an interactive confirmation prompt whenever a file transfer
threatens to replace an existing file. Prior to MS-DOS version 6.2,
executing a COPY command would silently overwrite identical
filenames in the destination directory without warning. MS-DOS 6.22
addresses this conflict risk directly by requiring explicit user
permission before replacing data, providing command-line override
switches, and supporting global environment variables to control
overwrite behavior.
Interactive Overwrite Prompts
When executing a COPY command where the target directory
contains a file matching the destination filename, MS-DOS 6.22 halts the
operation and displays a prompt:
Overwrite destination (Yes/No/All)?
The user must provide one of three inputs to proceed:
- Y (Yes): Overwrites the current conflicting file and continues the process.
- N (No): Skips copying the conflicting file, preserving the original file in the destination directory, and moves to the next file if a wildcard was used.
- A (All): Overwrites the current file and all subsequent conflicting files encountered during that specific command execution without asking again.
Command Switches: /Y and
/-Y
To provide flexibility between automated workflows and data safety,
MS-DOS 6.22 introduced the /Y and /-Y flags
for the COPY, MOVE, and XCOPY
utilities:
/Y: Instructs the command to overwrite existing destination files immediately without prompting for confirmation./-Y: Explicitly forces the command to prompt the user before overwriting an existing file, ensuring protection even if default settings have been altered.
The COPYCMD Environment Variable
Users can set system-wide overwrite behavior using the
COPYCMD environment variable, typically configured inside
the AUTOEXEC.BAT startup file.
By executing SET COPYCMD=/Y, an administrator can
restore the legacy behavior of MS-DOS, forcing COPY to
overwrite files silently by default. Conversely, setting
SET COPYCMD=/-Y guarantees that confirmation is always
required. When COPYCMD is set, a user can still override
the environment variable on an ad-hoc basis by passing the opposite
switch directly in the command line (for example, typing
COPY /-Y source.txt target.txt when COPYCMD is
set to /Y).
Behavior in Batch Files
To preserve backward compatibility with legacy automation scripts,
MS-DOS 6.22 handles batch files differently than interactive
command-line sessions. When a COPY command is executed from
within an automated .BAT script, the operating system
defaults to suppressing the overwrite prompt, behaving as if the
/Y switch were present. This prevents unattended batch
routines from hanging indefinitely while waiting for keyboard input.
Script authors who require overwrite safety within batch scripts must
explicitly append the /-Y switch to their commands.