Home > Commands N-Z > Commands R


Description | Syntax | Parameters | Switches | Related | Notes | Examples | Errorlevels | Availability

Replaces files in a destination directory with files in a source directory that have the same name. You can also use REPLACE to add unique filenames to the destination directory.



REPLACE [drive1:][path1]filename [drive2:][path2] [[/A] | [/S] [[/D] | [/U]]] [/P] [/R] [/W]

drive1: ( path1 filename v3.2 Win95 NT3.5)
Specifies the location and name of the source file or set of files.
drive2: ( path2 v3.2 Win95 NT3.5)
Specifies the location of the destination file. You cannot specify a filename for files you replace. If you specify neither a drive nor a directory, REPLACE uses the current drive and directory as the destination.

/? (NTXP)
Displays help.
/A (v3.2 Win95 NT3.5)
Adds new (missing) files to the destination directory instead of replacing existing files. You cannot use this switch with the /S or /U switch.
/P (v3.2 Win95 NT3.5)
Prompts you for confirmation before replacing a destination file or adding a source file.
/R (v3.2 Win95 NT3.5)
Replaces read-only files as well as unprotected files. If you do not specify this switch but attempt to replace a read-only file, an error results and stops the replacement operation.
/S (v3.2 Win95 NT3.5)
Searches all subdirectories of the destination directory and replaces matching files. You cannot use the /S switch with the /A switch. The REPLACE command does not search subdirectories specified in path1.
/D (v3.30 through v4.0)
/U (v5.0 Win95 NT3.5)
Replaces (updates) only those files on the destination directory that are older than those in the source directory. You cannot use the /U (or /D) switch with the /A switch.
/W (v3.2 Win95 NT3.5)
Waits for you to insert a disk before REPLACE begins to search for source files. If you do not specify /W, REPLACE begins replacing or adding files immediately after you press ENTER.


ATTRIB - Changing file attributes.
ROBOCOPY - Robust File and Folder copy.
MOVE - Move files from one folder to another folder on the same drive.
DEL - Delete one or more files.
COPY - Copy one or more files to another location.
Equivalent Linux BASH commands:
install - Copy files and set attributes.

REPLACE messages

As REPLACE adds or replaces files, the operating system displays their filenames on the screen. After the REPLACE command is finished, the operating system displays a summary line in one of the formats:

    nnn files added
    nnn files replaced
    no file added
    no file replaced

Replacing files on a floppy disk system

If you have a floppy disk system and need to switch disks during the REPLACE operation, you can specify the /W switch so that REPLACE will wait for you to switch disks, as necessary.

Limitations on REPLACE

You cannot use the REPLACE command to update hidden files or system files such as IO.SYS and MSDOS.SYS. For information about changing hidden and system attributes, see the ATTRIB command.


Suppose that several directories on drive C contain different Versions of a file named PHONES.CLI, which contains client names and phone numbers. To replace all of these files with the latest version of the PHONES.CLI file from the disk in drive A, type:


Suppose you want to add new printer device drivers to a directory on drive C named TOOLS, which already contains several printer device-driver files for a word processor. To do this, type:


This command searches the current directory on drive A for any files that have the extension .PRD and then adds these files to the TOOLS directory on drive C. Because the /A switch is included, REPLACE adds only those files from drive A that do not exist on drive C.

v3.20 v3.05 v3.1 v3.21 v3.25 v3.30 v3.3A v3.3R v3.3T v3.31 v3.40 v4.0 v4.01 v4.01A v5.0 v5.0A v5.00.02 v5.001A v5.01 v5.02 v6.0 v6.10 v6.2 v6.21 v6.22 v6.23 v7.00 v7.0R1 v7.10
Win95 Win98
Windows NT
NT3.5 NT4 NT2000 NTXP NT2003