xcopy - is there a switch that disables confirmation for overwrite?

Muse

Lifer
Jul 11, 2001
37,505
8,102
136
I have a batch file that backs up certain files and folders with subfolders. I'm using xcopy with commands like this:

xcopy D:\notes /S N:\notes
xcopy D:\images /S N:\images

But for each such command I get asked a question like this:

Overwrite D:\notes\<filename> (Yes/No/All)?

Isn't there a switch that will save my having to enter "A" for each command? Thanks.
 

CTho9305

Elite Member
Jul 26, 2000
9,214
1
81
xcopy /?
...
...
/U Copies only files that already exist in destination.
/K Copies attributes. Normal Xcopy will reset read-only attributes.
/N Copies using the generated short names.
/O Copies file ownership and ACL information.
/X Copies file audit settings (implies /O).
/Y Suppresses prompting to confirm you want to overwrite an
existing destination file.

/-Y Causes prompting to confirm you want to overwrite an
existing destination file.
...
...
 

Muse

Lifer
Jul 11, 2001
37,505
8,102
136
Originally posted by: CTho9305
xcopy /?
...
...
/U Copies only files that already exist in destination.
/K Copies attributes. Normal Xcopy will reset read-only attributes.
/N Copies using the generated short names.
/O Copies file ownership and ACL information.
/X Copies file audit settings (implies /O).
/Y Suppresses prompting to confirm you want to overwrite an
existing destination file.

/-Y Causes prompting to confirm you want to overwrite an
existing destination file.
...
...

Thanks a ton for this. Does the /S switch do anything or does xcopy copy subdirectories by default?

Edit: Something crazy's happening. Somehow it's not getting all the files. I haven't gotten to the bottom of it. There's some files in one subfolder that are not getting copied with this command:

Xcopy e:\fox\dj /S /Y N:\fox\dj

That is to say (for instance):

There's a file E:\Fox\DJ\Programs\test.txt

After running the batch file that includes the above command, there is no N:\Fox\DJ\Programs\test.txt

Why?

I can see the batch file running, and evidently some of the E:\Fox\DJ\Programs\ files are being copied.

Edit2: So, I decide to do an experiment. I rename the folder N:\fox\dj\programs to N:\fox\dj\programs-tail

I rerun the batch file and this time all the files I expect to find in N:\fox\dj\programs are there! Please, please someone explain. Am I losing my mind? This is ludicrous. BTW, I'm running Windows 2000 SP4... I need a backup solution that I have confidence in. I used to just copy/paste directories in Windows Explorer, and sure that works, but it would be a lot easier to just run a batch file periodically. Of course, there's important files not being copied. I'm talking about files that have changed, been updated since last copied to the N: partition. Also, that test.txt file wasn't copied at all. :confused:
 

Kwatt

Golden Member
Jan 3, 2000
1,602
12
81
Originally posted by: Muse
I have a batch file that backs up certain files and folders with subfolders. I'm using xcopy with commands like this:

xcopy D:\notes /S N:\notes
xcopy D:\images /S N:\images

But for each such command I get asked a question like this:

Overwrite D:\notes\<filename> (Yes/No/All)?

Isn't there a switch that will save my having to enter "A" for each command? Thanks.



I don't know what OS you are using.

Is there a reason you need to overwrite every file?
I f you add /m to this "xcopy D:\notes /S N:\notes" change it to "xcopy D:\notes /m/S N:\notes" only the files that have been added to the folder or the files that have changed since the last time you ran the batch file will be copied.

I'm using Win 2K. My batch file is run at 3:00 AM by using task sch.




Kwatt



EDIT: I type too slow you posted while I was sleeping at the keyboard:)
 

SearchMaster

Diamond Member
Jun 6, 2002
7,792
114
106
You might also want to look on Microsoft's site for the Resource Kit for your O/S version. There is a tool called robocopy that is a more complete file copying utility.
 

Muse

Lifer
Jul 11, 2001
37,505
8,102
136
Originally posted by: Kwatt
<blockquote>Quote
Originally posted by: Muse
I have a batch file that backs up certain files and folders with subfolders. I'm using xcopy with commands like this:

xcopy D:\notes /S N:\notes
xcopy D:\images /S N:\images

But for each such command I get asked a question like this:

Overwrite D:\notes\<filename> (Yes/No/All)?

Isn't there a switch that will save my having to enter "A" for each command? Thanks.



I don't know what OS you are using.

Is there a reason you need to overwrite every file?
I f you add /m to this "xcopy D:\notes /S N:\notes" change it to "xcopy D:\notes /m/S N:\notes" only the files that have been added to the folder or the files that have changed since the last time you ran the batch file will be copied.

I'm using Win 2K. My batch file is run at 3:00 AM by using task sch.




Kwatt



EDIT: I type too slow you posted while I was sleeping at the keyboard:)[/quote]I'm using Win2000 SP4. There's no reason I have to overwrite every file. Only changed files is absolutely fine. Trouble is, for some mysterious (to me) reason, there were some files that had changed that weren't being overwritten. That's NOT OK! I'll try that command you gave with the added /M switch. But why was I having the problem I indicate - some files not being overwritten, and what's more ... a new file not being copied?

 

Muse

Lifer
Jul 11, 2001
37,505
8,102
136
Originally posted by: SearchMaster
You might also want to look on Microsoft's site for the Resource Kit for your O/S version. There is a tool called robocopy that is a more complete file copying utility.
Thanks, I'll look into robocopy. But I can't understand why xcopy or even copy isn't up to my requirements. My batch file just has 4 commands in it similar to the one I indicate.