CMD Replace file replacement usage Instructions _dos/bat

Source: Internet
Author: User
Tags switches
Help information:
Copy Code code 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 where you want to replace the file.
/A Add the new file to the target directory. cannot be paired with/S or/u command-line switches
Use.
/P will prompt you for confirmation before you replace the file or join the source file.
/R replaces read-only files and unprotected files.
/S replaces files for all subdirectories in the destination directory. Cannot match/a command switch
With the use.
/w Wait until you insert the disk before you run it.
/u replaces or updates only files that are older than the source file date. cannot be with/a command line
Switch to use.

Command summary:
Replace, all English replace, meaning: replacement, under the jurisdiction of 6 parameters.
Copy Code code as follows:

REPLACE [Drive1:][path1]filename [Drive2:][path2]

Use conditions for Replace:
:: Reference syntax, so that the light rod replace condition has two
1. Replace and replaced files with the same name (according to: Destination only file path, no filename)
2. Two files must be in a different path (according to: Files of the same name cannot be in the same folder)
This is true after testing.
Detailed parameter:/A To add the new file to the target directory. cannot be used with/S or/u command line switches.
/A, English full name Add, meaning: Add.
/A parameter cannot be used with/s,/U.
/A parameter is not so much as "add a new file to the target directory", rather "copy the new file to the target directory", so raplace/a can be used as copy/y, but the grammar should pay attention to the difference.
Example: Copy 1.txt to C packing directory:
Copy Code code as follows:

c:\users\hellow~1\desktop>replace/a 1.txt C:\

/P will prompt you for confirmation before you replace the file or join the source file.
Copy code/p, English full name prompt, meaning: hint.
As the name suggests, is the hint, the effect:
Copy Code code as follows:

c:\users\hellow~1\desktop>replace/p 1.txt C:\
Do you want to replace C:\1.txt? (y/n)

Copy Code code as follows:

/R replaces read-only files and unprotected files.

/R, English full name read, meaning: Reading, this can be extended to read-only files.
With this parameter, it can be foreseen that the replace can not replace the read-only file by default, which is tested indeed.
Copy Code code 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 Code code as follows:

/S replaces files for all subdirectories in the destination directory. cannot be used with the/a command switch.

/s, English full name subdirectory, meaning: Sub directory.
/s can replace files in all subdirectories under the specified directory.
For example: There are two txt files, their complete path is C:\1.txt c:\hello\1.txt, with the/s parameter to replace them all at once.
Copy Code code as follows:

C:\USERS\HELLOW~1\DESKTOP>REPLACE/S/R 1.txt C:\
Replacing C:\1.txt
Replacing C:\hello\1.txt

Copy Code code as follows:

/w Wait until you insert the disk before you run it.

/w, the English full name wait, meaning: waiting.
This command does not explain, the disk should refer to the floppy disk; This command is not difficult to see "Kiss to Death" on Cmd.exe only a "continuity" of the "Shing", there is no "with The Times" "I Love You,i need you,i the want You" of the passion, yes, Windows does not love cmd, he just cherish her only ...
/u replaces or updates only files that are older than the source file date. cannot be with/a command line
Switch to use.
/u, English full name update, meaning: updated.
This parameter is very magical, the number of replace is the most my heart.
For example: first create two text, C disk first created, D disk after the creation
Copy Code code 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/u parameter to replace c:\1.txt to D disk
Copy Code code 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!

You can see that the 1.txt in D is not replaced, why? Since D:\1.txt is created after c:\1.txt, in other words: D:\1.txt is newer than c:\1.txt.
Even so, the converse is naturally established:
Copy Code code 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.