Computer Hope

Microsoft => Microsoft DOS => Topic started by: kvnsdr on August 04, 2005, 08:48:14 AM

Title: XCOPY Error LOG?
Post by: kvnsdr on August 04, 2005, 08:48:14 AM
I use the following XCOPY syntax to backup to an external HDD:

xcopy /h /i /c /s /e /y C:\"Documents and Settings"\*.* G:\Backup\ /d


Q. How can I create an error log?

Q. How can I log files changed / new files copied?
Title: Re: XCOPY Error LOG?
Post by: Gizmo73 on August 04, 2005, 09:29:06 AM
This code may work:

set log=c:\xcopy.log
set error=c:\xcopy.error.log
echo %date% %time% >> %log%
echo %date% %time% >> %error%
xcopy "c:\mirc\*.*" c:\test\ /c/y/i/e/v/f >> %log% 2>> %error%

[glb]Gizmo73[/glb]
Title: Re: XCOPY Error LOG?
Post by: kvnsdr on August 04, 2005, 12:19:28 PM
It works!

Q. What does the 2 >> mean?

Q. Can I put another 3 >> %user% behind it?
Title: Re: XCOPY Error LOG?
Post by: Sidewinder on August 04, 2005, 02:28:17 PM
DOS commands allocate devices for it's output. STDOUT which is used generally for informational messages that record the programs progress and STDERROR which is used for errors. By using >> %log%, you redirected the STDOUT data stream to whatever device %log% defined; by using 2>> %error% you redirected the STDERROR data stream to whatever device %error% defined.

I am not aware of a third device, but DOS can be quirky, so you never know.;)

Hope this helps. 8)