I need my program to run:
xcopy s:\* z:\ /E
When xcopy runs, it will prompt if a file needs to be overwritten, so I want the batch file to answer no in all cases to the prompt.
How can I accomplish this?
Copies source files changed on or after the specified date only. If you do not include a MM-DD-YYYY value, xcopy copies all source files that are newer than existing destination files. This command-line option allows you to update files that have changed.
If you are copying files using drag-drop or copy/paste, you may simply choose “Skip this file” or “Skip these files” option to not overwrite the files that are already existed at the destination folder. Or, if you are using command line copy, you can answer N to bypass these files that are already existed.
If the copy command is run from within a batch job you do not need to use the /Y switch: it will overwrite existing files.
All you have to do is hold down the Shift key while you click on no. It has the same effect as saying No To All which means that the copy process from that moment on will automatically select no if a duplicate file is found in the destination directory.
I almost overlooked this in the switches myself. I was aided by an Experts Exchange article.
Here is the switch of significance:
/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.
The "If no date is given" portion is of particular importance. This doesn't exactly answer the "without the overwriting existing files" question, but it does answer it if the existing file's time stamp of the source file is not newer than the destination file.
Close enough for government work.
I've been using the following flags for years. It seems to accomplish all the behaviors you describe in the question.
xcopy s:\ z:\ /S /Y /D
S will copy all subfolders and files within them Y prevents any overwrite prompts D essentially copies anything newer than what is already in the destination
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With