XCOPY without prompting

S

Swifty

Is there an XCOPY switch to tell tell it that the destination is a file and
not to prompt? Like the opposite of /I ?

The command "xcopy c:\temp\x.x c:\temp\y.y /y" will not produce a prompt if
the destination file already exists, but if it does not exist, you get:

Does C:\temp\y.y specify a file name
or directory name on the target
(F = file, D = directory)?

I'm trying to use xcopy in a simple backup process, so I have a workaround:
I can check if the destination file exists, and if it doesn't then create
it just before attempting the xcopy, but this is pretty horrible...
 
S

Shenan Stanley

Swifty said:
Is there an XCOPY switch to tell tell it that the destination is a
file and not to prompt? Like the opposite of /I ?

The command "xcopy c:\temp\x.x c:\temp\y.y /y" will not produce a
prompt if the destination file already exists, but if it does not
exist, you get:

Does C:\temp\y.y specify a file name
or directory name on the target
(F = file, D = directory)?

I'm trying to use xcopy in a simple backup process, so I have a
workaround: I can check if the destination file exists, and if it
doesn't then create it just before attempting the xcopy, but this is
pretty horrible...

You are trying to use XCOPY to rename and copy into the same directory..
Why not use copy..? Or copy the files you want to backup to a different
directory instead of renaming?

For example, backup just the contents of your My Documents folder that have
changed to the D drive:

xcopy "C:\Documents and Settings\YOUR_USERNAME\My Documents\*.*" "D:\My
Documents (BACKUP)" /E /D /C /H /R /K /O /Y

If you want to do whatever it was you were trying to do (copy the file into
the same directory with a new name, I guess) then use the copy command..

copy /y c:\temp\x.x c:\temp\y.y
 
S

Swifty

Specifying the same input and output directory was a mistake on my part -
the backup process I'm building copies files on C: to somewhere on D: and
vice-versa. C: and D: are on different physical discs, so my backup
protects me from media failure.

The reason I'm using XCOPY is so that I can copy only files which have the
archive bit set (and to reset it in the process) so I do not endlessly copy
files which have not changed.

I added my workaround (creating a null output file just before the xcopy)
and I'm content with this mechanism.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top