Friday, May 23, 2008

XCOPY redirect stdout and stderr

Created a script to copy files called migrate.cmd. With this script I can do an initial copy of everything. I could then rerun it to copy only new files during the day of migration. Speeds things up quite a bit to only have to copy changed files from the day before.

But found that any errors produced still went to the console or command line and I couldn't see which files it complained.. Finally found the syntax to redirect stderr to stdout and redirect all of stdout(with stderr) into a file.

Here it is

xcopy /D /I /E /C /F /H /R /K /O /Y f:\data l:\data > migrate.log 2>&1

No comments: