; define the RoboCopy command parameters and arguments - copy all subfolders including empty subfolders from $Src to \\$Target\$Dst
; $Exclude contains exclude statement (if any); $RCArgs contains extra RoboCopy args (if any)
; 2 retries on failure, 5 second delay on retry, $RCLogFile contains filespec for log file
$Cmd = '%COMSPEC% /c ' + $BIN + 'robocopy ' + $Src + ' \\' + $Target + '\' + $Dst + $Exclude + $RCArgs + ' /E /R:2 /W:5 /LOG+:' + $RCLogFile
fMsg(' Copying from ' + $Src + ' to ' + $Dst, '', 1, 16) ; Log the copy operation
If Not $DEBUG
Shell $Cmd
If @ERROR > 7 ; error copying files if 8 or higher
$Err = 1 ; set global error flag
$fErr = $fErr + 4 ; set RoboCopy error bit
$SErr = ' Error: ' ; Handle robocopy error/exit codes (V1.3)
Else
$SErr = ' Success: '
EndIf
$SErr = $SErr + @ERROR + ' - '
If @ERROR & 16
$SErr = $SErr + 'Fatal error, no files copied. '
EndIf
If @ERROR & 8
$SErr = $SErr + 'Copy errors, retry exceeded. '
EndIf
If @ERROR & 4
$SErr = $SErr + 'Mismatched files/folders detected, '
EndIf
If @ERROR & 2
$SErr = $SErr + 'Extra files/folders detected, '
EndIf
If @ERROR & 1
$SErr = $SErr + '1+ Files copied, '
EndIf
If @ERROR = 0
$SErr = 'Warning! No files copied. '
EndIf
EndIf
fMsg(': ' + $SErr, '', 0, 17) ; append result to log
fMsg(' Cmd: ' + $Cmd, '', 0, $DbgLog) ; show command if debug mode
Next ; next path