The following is an example of the use of Mcopy.exe and Mtc.exe with variables and error-checking in a batch file:
REM
REM Set global variables
REM
set log=Mylog.log
set errlog=error.log
set sourcetree=\\neptune\binaries
set buildtree=e:\myproject
REM
REM Create destination directories
REM
MD %buildtree%
MD %buildtree%\bin
Mcopy %log% %sourcetree%\readme.doc %buildtree%\bin\readme.doc
MTC %log% %sourcetree%\abc\tools %buildtree%\abc\tools\
MTC %log% %sourcetree%\def %binaries%\def\
:ERRORCHK
findstr /I matching %LOG% > %ERRLOG%
findstr ERROR %LOG% >> %ERRLOG%
qgrep -y ERROR %ERRLOG% > nul
if errorlevel 1 goto NEXT
start "LOG HAS AN ERROR(S)!!!" list %ERRLOG%
goto SKIP
:NEXT
qgrep -y matching %ERRLOG% > nul
if errorlevel 1 goto NO_ERROR
start "LOG HAS AN ERROR(S)!!!" list %ERRLOG%
goto SKIP
:NO_ERROR
start "LOG HAS NO ERROR in it." list %ERRLOG%
Goto SKIP
:SKIP
GOTO END
:END