The replace command in Windows
The replace command helps replace files. If used with the / a option, the replace command will add new files to a directory instead of replacing existing files.To learn more about how to use this command, see the example section below.
Replace command syntax
replace [:] [] [:] [] [/ a] [/ p] [/ r] [/ w]
replace [:] [] [:] [] [/ p] [/ r] [/ s] [/ w] [/ u]
Replace command parameter
Parameters
Describe
[:] []
Specify the location and name of the source file or set of files to replace.FileName is a required parameter and can include wildcards (* and?).
[:] []
Specify the location of the destination file.You cannot specify file names for files you want to replace.If you do not specify a drive or path, the replace command will use the current drive and directory as the destination file by default.
/ a
Add new files to the target directory instead of replacing existing files.You cannot use this command line option together with the command line option / s or / u .
/ p
Remind you to confirm before replacing a destination file or adding a source file.
/ r
Replace Read-only files and unprotected.If you try to replace a Read-only file, but you did not specify the / r parameter, the returned result will report an error and stop executing the replace command.
/ w
Wait for you to add a disk before the process of finding source files begins.If you do not specify the / w parameter, the replace command will start replacing or adding files immediately after you press ENTER.
/S
Search all subdirectories in the destination directory and replace the appropriate files.You cannot use the / s parameter with the command line option / a . The replace command will not search for subdirectories specified in Path1 .
/ u
Replace only the files on the target folder older than those in the source directory.You cannot use the / u parameter with the command line option / a .
/?
Show help at thecommand prompt.
Note the replace command
When the replace command adds or replaces files, the file name will be displayed on the screen. After the replace command is executed, a summary line will be displayed in one of the following formats:
nnn tập tin thêm nnn tập tin không thay thế tập tin thêm không có tập tin
If you are using a floppy disk and you need to convert the disk during the replacement process, you can specify the / w command line option to replace the replace command that will be suspended while you convert the disk.
You cannot use the replace command to update hidden files or system files.
The following table shows each exit code and a brief description of the meaning of these codes:
Exit code
Describe
0
The replace command has successfully replaced or successfully added the files.
first
The replace command encountered an incorrect MS-DOS version.
2
The replace command cannot find the source files.
3
The replace command cannot find the source or destination path.
5
Users do not have access to the files you want to replace.
8
There is not enough system memory to execute the command.
11
The user has used the wrong syntax on the command line.
Note:
You can use the ERRORLEVEL parameter on the if statement in a batch program to handle exit codes returned by the replace command.
For example the replace command
To update all versions of a file named Phones.cli (appearing in multiple folders on drive C), with the latest version of the Phones.cli file from the floppy disk in drive A, enter:
replace a: phones.cli c: / s
See more:
- The qprocess command in Windows
- Qappsrv (query termserver) command in Windows
- The quser (query user) command in Windows
- The pubprn command and the pushprinterconnections command in Windows
You should read it
- 6 Best Command Prompt Alternatives for Windows
- REPLACE function in SQL Server
- Signs that you need a new modem
- Del command in Windows
- Set command in Windows
- The insurance center in Vietnam confirmed that the users of the old iPhone will be replaced with the battery for $ 29
- Cmd command in Windows
- Instructions for searching and replacing in Excel tables
May be interested
- Rem command in Windowsthe rem command helps write comments (comments) in a batch file or config.sys.
- Use PowerShell to download any file on Windows 10windows powershell is a tool built into windows 10. this tool has the ability to set up more features than command prompt, better operating system control .... most likely, powershell will replace command prompt in the future.
- How to customize Windows Terminal applicationwith the new windows terminal application, windows finally has a tabbed terminal that can run command prompt, powershell and bash in the same window. and it's highly customizable, you can even set animated gifs as wallpapers.
- Instructions for using Command Promptdeep in windows is a command-line world that is obscure. in this article, we will show you how to solve errors and make your computer more secure.
- Rd command in Windowsthe rd command helps delete a directory
- Cmd command in Windowsthe cmd command starts a new version of the command interpreter, cmd.exe. if used without parameters, cmd will display copyright information and the version of the operating system.
- How to use the command history function in Command Promptcommand prompt is an extremely familiar command for anyone using windows operating system. besides, a lot of current software also supports the command line to perform actions on the command prompt window, instead of on the screen.
- The sfc command in Windows(applies to windows server (semi-annual channel), windows server 2016, windows server 2012 r2, windows server 2012)
- Reg command copy in Windowsto copy an entry to the location specified on the local pc or the remote computer we will use the reg copy command. to learn more about how to use the reg copy command, you can track the syntax, explain the command parameters and the example tipsmake.com has compiled below.
- Fc command in Windowsthe fc command compares two files or a collection of files and displays the differences between them.