REPLACE(DOS) UNIX System V REPLACE(DOS)
Name
replace - replaces files
Syntax
replace [drive:]pathname [drive:][path]
[/a][/d][/p][/r][/s][/w]
Description
The replace command lets you easily update files on your
hard disk with new versions of software.
The replace command performs two functions:
⊕ By default, it replaces files in the target directory
with files in the source directory that have the same
name. You may use wildcards in source filenames.
⊕ When you specify the /a switch, replace adds files that
exist in the source directory (but not in the target
directory) to the target directory.
The switches are:
/a Adds new files to the target directory instead of
replacing existing ones. You may not use this switch
with either the /d or /s switch.
/d Replaces files in the target directory only if the
source files are newer than the corresponding target
files. This switch is incompatible with the /a switch.
/p Prompts you with the following message before it
replaces a target file or adds a source file:
Replace filename? (Y/N)_
/r
Replaces read-only files as well as unprotected files. If
you do not specify this switch, any attempt to replace a
read-only file causes an error and stops the replace
process.
/s
Searches all subdirectories of the target directory while it
replaces matching files. This switch is incompatible with
the /a switch. The replace command never searches
subdirectories in the source path.
/w
Waits for you to hit any key before it replaces any files.
If you do not specify this switch, replace begins replacing
or adding files immediately.
As files are replaced or added, replace displays the
filenames on the screen; then at the conclusion of the
replace operation, it displays a summary line:
NNN file(s) added/replaced
or:
No files added/replaced
Examples
Suppose your hard disk, drive C, contains several old files
named phones.cli that contain client names and phone
numbers. To update these files and replace them with the
latest version of the phones.cli file on the disk in drive
A, you would enter the following command:
replace a:\phones.cli c:\ /s
This command replaces every file on drive C that is named
phones.cli with the file phones.cli from the root directory
on drive A.
Suppose you want to add some new printer device drivers to a
directory called c:\mstools, which already contains several
printer driver files for a word processor. To do this, you
would enter the following:
replace a:*.prd c:\mstools /a
This command searches the default directory of drive A for
any files that have the extension .prd (that don't currently
exist in the \mstools directory on drive C) and then adds
these files to c:\mstools.
Upon completion, replace returns one of the following exit
codes:
0 Command successful
1 Command line error
2 File not found
3 Path not found
5 Access denied
8 Insufficient memory
15 Invalid drive
Other Standard MS-DOS error
You can test for these codes by using the errorlevel
condition of the batch processing if command.
Notes
You cannot use replace to update hidden files or system
files.
replace is an external command.
REPLACE(DOS) (printed 8/16/89) REPLACE(DOS)