Cmd replace file replacement instructions

Source: Internet
Author: User

Help information: Copy codeThe Code is as follows: Replace the file.
REPLACE [drive1:] [path1] filename [drive2:] [path2] [/A] [/P] [/R] [/W]
REPLACE [drive1:] [path1] filename [drive2:] [path2] [/P] [/R] [/S] [/W] [/U]
[Drive1:] [path1] filename specifies the source file.
[Drive2:] [path2] specifies the directory of the file to be replaced.
/A adds the new file to the target directory. Cannot be used with/S or/U command line switch
.
You will be prompted to confirm before/P replaces the file or adds the source file.
/R replace read-only and unprotected files.
/S replaces all subdirectories in the target directory. Cannot be used with the/A command switch
Configuration.
/W.
/U only replaces or updates files earlier than the source file date. Cannot match the/A command line
Switch.

Command summary:
Replace: replace. It has six parameters.Copy codeThe Code is as follows: REPLACE [drive1:] [path1] filename [drive2:] [path2]

Replace usage conditions:
: Refer to the syntax. There are two condition for using the pole replace
1. Replace and replace the file with the same name (according to: the target only has the file path, no file name)
2. The two files must be in different paths (the files with the same name cannot be in the same folder)
It was tested to be true.
Parameter description:/A adds the new file to the target directory. It cannot be used with the/S or/U command line switch.
/A. The full name is "add.
The/a parameter cannot be used with/s or/u.
The/a parameter is not so much "copying a new file to the target directory" as "copying a new file to the target directory". Therefore, rappers/a can be used for copy/y, but pay attention to the difference in syntax.
Example: Copy 1.txt to the c root directory:Copy codeThe Code is as follows: C: \ Users \ HELLOW ~ 1 \ Desktop> replace/a 1.txt c :\

You will be prompted to confirm before/P replaces the file or adds the source file.
Copy the code/p, which is the full name of prompt, meaning: prompt.
As the name implies, it is a prompt. effect:Copy codeThe Code is as follows: C: \ Users \ HELLOW ~ 1 \ Desktop> replace/p 1.txt c :\
Do you want to replace C: \ 1.txt? (Y/N)

Copy codeThe Code is as follows:/R replaces read-only and unprotected files.

/R, the full name of read, meaning: read; here can be extended to read-only files.
This parameter exists. It is foreseeable that the replace cannot replace the read-only file by default. This is true after testing.Copy codeThe Code is as follows: C: \ Users \ HELLOW ~ 1 \ Desktop> attrib + r c: \ 1.txt
C: \ Users \ HELLOW ~ 1 \ Desktop> replace 1.txt c :\
Access denied-C: \ 1.txt
File not replaced
C: \ Users \ HELLOW ~ 1 \ Desktop> replace/r 1.txt c :\
Replacing C: \ 1.txt

Copy codeThe Code is as follows:/S replaces all subdirectories in the target directory. It cannot be used with the/A command switch.

/S, full name of subdirectory, meaning: subdirectory.
/S can replace all subdirectories in a specified directory,
For example, there are two txt files whose full paths are c: \ 1.txt c: \ hello \ 1.txt. replace them all with the/s parameter.Copy codeThe Code is as follows: C: \ Users \ HELLOW ~ 1 \ Desktop> replace/s/r 1.txt c :\
Replacing C: \ 1.txt
Replacing C: \ hello \ 1.txt

Copy codeThe Code is as follows:/W. After you insert a disk, run it again.

/W. The full name is wait.
There is only one kind of "I love you, I need you, I want you" that is "easy to follow, windows doesn't like cmd. He just cherishes her ......
/U only replaces or updates files earlier than the source file date. Cannot match the/A command line
Switch.
/U, full name of update, meaning: update.
This parameter is amazing. The Number Parameter in replace is the most important.
For example, create two texts first, create a drive C, and create a drive D.Copy codeThe Code is as follows: C: \ Users \ HELLOW ~ 1 \ Desktop> echo I'm first!> C: \ 1.txt
C: \ Users \ HELLOW ~ 1 \ Desktop> echo I'm Second!> D: \ 1.txt

Then add the/u parameter to replace c: \ 1.txt with drive D.Copy codeThe Code is as follows: C: \ Users \ HELLOW ~ 1 \ Desktop> d: \ 1.txt
C: \ Users \ HELLOW ~ 1 \ Desktop> replace/u c: \ 1.txt d :\
C: \ Users \ HELLOW ~ 1 \ Desktop> type d: \ 1.txt
I'm Second!

It can be seen that the D Drive 1.txt is not replaced. Why? Because d: \ 1.txt is created after c: \ 1.txt, in other words, d: \ 1.txt is newer than c: \ 1.txt.
In this case, the opposite is true:Copy codeThe Code is as follows: C: \ Users \ HELLOW ~ 1 \ Desktop> replace/u d: \ 1.txt c :\
Replacing C: \ 1.txt
C: \ Users \ HELLOW ~ 1 \ Desktop> type c: \ 1.txt
I'm Second!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.