默认情况下,从命令提示符进行复制将提示您覆盖目标位置中已存在的文件.
您可以添加"/ Y"来表示"是对所有人"替换.
但你怎么能说"不对所有人"?
换句话说,我要复制一切从一个目录,它不是已经在目标存在.
我看到的最接近的是XCOPY参数,只能在特定的mod-datetime之后复制东西.
小智 29
echo "No" | copy/-Y c:\source c:\Dest\
Run Code Online (Sandbox Code Playgroud)
小智 21
您可以使用单个长行"n"创建一个文本文件,然后运行您的命令并在其后面输入<nc.txt.我这样做是为了复制超过145,000个实例,其中"No overwrite"是我想要的,并且它以这种方式运行良好.
或者你可以用一些东西按住n键,但这需要比使用<管道输入更长的时间.
我使用XCOPY以下参数来复制.NET程序集:
/D /Y /R /H
/D:m-d-y - Copies files changed on or after the specified date. If no date is given, copies only those files whose source time is newer than the destination time.
/Y - Suppresses prompting to confirm you want to overwrite an existing destination file.
/R - Overwrites read-only files.
/H - Copies hidden and system files also.
Run Code Online (Sandbox Code Playgroud)
小智 6
我知道你们都认为/ D:日期会使用日期的东西,但只有/ D没有:确实是我们想要的......
xcopy {Source} {Destination} /E /D
Run Code Online (Sandbox Code Playgroud)
在没有覆盖的情况下进行复制,以便在出于某种原因之前拾取那些新的或可能失败的文件.
试试吧,它有效.
答对了:
http://www.xxcopy.com/xxcopy27.htm#tag_231
2.3 By comparison with the file in destination
The switches in this group select files based on the
comparison between the files in the source and those in
the destination. They are often used for periodic backup
and directory synchronization purposes. These switches
were originally created as variations of directory backup.
They are also convenient for selecting files for deletion.
2.3.1 by Presence/Absence
The /BB and /U switches are the two switches which select
files by the pure presence or absence as the criteria.
Other switches in the this group (Group 2.3) are also
affected by the file in the destination, but for a
particular characteristics for comparison's sake.
/BB Selects files that are present in source but not in destination.
/U Selects files that are present in both source and destination.
Run Code Online (Sandbox Code Playgroud)
-亚当
这工作正常
no | cp -rf c:\source c:\Dest\
Run Code Online (Sandbox Code Playgroud)