Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

DOS Switch Question

Status
Not open for further replies.

dschmootz

IS-IT--Management
Oct 30, 2002
100
0
0
US
Hi All,

I want to create a batch file that copies all files in C:\folder to F:\folder (F is another PC) as a backup. Should I use "backup" or "copy" and what switch would make it overwrite only changed files? I don't want it to ask me if I want to overwrite. This is what I have in a .bat file:

xcopy c:\folder\*.* f:\folder\*.* /c /h /s /d

Thanks for the help in advance!
DON
 
What you've got is fine but I would use /e instead of /s so that empty folders get copied, use /v so the copied files are verified to be the same as the source and /r so that readonly files can be overwritten.

Incidentally you don't need the *.* in the destination parameter:

xcopy C:\Folder\*.* F:\Folder\ /c/h/e/v/r/d

IMHO xcopy is better than both backup and copy for this task. An alternative is to use a compression utility such WinZip but this won't copy empty folders.

You might also wish to pipe the output from xcopy to a file that will serve as a log of what xcopy has done.


 
I suspect that I'd be looking at robocopy if I was on NT4 or later...
 
Strongm/bbofin,
I will try Robocopy, but I would also like to try XCOPY. bbofin, your switches are a great idea...thanks. However, it still asks me if I want to overwrite. I want it to just do it...no questions asked....smile. Any ideas?
 
Add a /y flag to the command to surpress the overwrite prompts (but I'd still be looking at robocopy... ;-))
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top