@Echo off

set MyCmd_DPN=%~DPN0%

:Menu
color 70
Echo ---------------------------------------------------------------------------
Echo MirToDir via Robocoy
Echo LastUpdate 20.02.2015 J.Fes
Echo ---------------------------------------------------------------------------
Echo.
if "%~1" equ "" (
  color C
  Echo  ERROR
  Echo  Info parameter for source Dir are send to this Batch
  Echo  Nothing can be done
  Pause
  goto :eof
)

Echo.
Echo List of directories to sync
Echo.

call :ListJobToDo %*

Echo.
Echo S  = Start Action
Echo Q  = Quit Action
Echo.
set /p doNext="Select Action: "

if /I "%doNext%" equ "S" goto :StartJob
if /I "%doNext%" neq "S" goto :NoJob
goto :Menu

:StartJob
call :RunJobToDo %*

goto :EndeJob



:EndeJob
 color A
 Echo.
 Echo -------------------------------------------------------------------------
 Echo Job is done
 Echo.
 call :ListJobToDo %*

 pause
 goto :MyEnd

:NoJob
 color C
 Echo.
 Echo -------------------------------------------------------------------------
 Echo Job NOT done
 pause
 goto :MyEnd

:MyEnd
goto :eof

rem ----------------------------------------------------------------------------

:RunJobToDo
color E
If "%~1" neq "" call :DoRoboCopy "%~1" RUN
If "%~2" neq "" call :DoRoboCopy "%~2" RUN
If "%~3" neq "" call :DoRoboCopy "%~3" RUN
If "%~4" neq "" call :DoRoboCopy "%~4" RUN
If "%~5" neq "" call :DoRoboCopy "%~5" RUN
If "%~6" neq "" call :DoRoboCopy "%~6" RUN
If "%~7" neq "" call :DoRoboCopy "%~7" RUN
If "%~8" neq "" call :DoRoboCopy "%~8" RUN
 goto :eof
rem ----------------------------------------------------------------------------
:ListJobToDo
 If "%~1" neq "" call :DoRoboCopy "%~1" VIEW
 If "%~2" neq "" call :DoRoboCopy "%~2" VIEW
 If "%~3" neq "" call :DoRoboCopy "%~3" VIEW
 If "%~4" neq "" call :DoRoboCopy "%~4" VIEW
 If "%~5" neq "" call :DoRoboCopy "%~5" VIEW
 If "%~6" neq "" call :DoRoboCopy "%~6" VIEW
 If "%~7" neq "" call :DoRoboCopy "%~7" VIEW
 If "%~8" neq "" call :DoRoboCopy "%~8" VIEW
 goto :eof
rem ----------------------------------------------------------------------------


:DoRoboCopy

 rem Path anpassen
 set T_DP=%~DP0%
 set Path=%T_DP%;%Path%

 rem Verzeichniss name aus Name Extrahieren
 set T_P=%~NX1%

 rem Source Root + Teilpath
 set S_DP=%~DP1%
 set S_DP=%S_DP%%T_P%

 rem Target Root + Teilpath
 set T_DP=%~DP0%
 set T_DP=%T_DP%%T_P%

 set Log_DPNE=%MyCmd_DPN%_%T_P%.log


 if "%~2" equ "RUN" (
   Echo ---------------------------------------------------------------------------
   Echo Robocopy Sync
 ) else (
   Echo.
 )

   Echo from Source Dir: "%S_DP%"
   Echo to Target Dir..: "%T_DP%"
   Echo RoboCopy.log...: "%Log_DPNE%"


 if "%~2" neq "RUN" goto :MyEnd
   rem /MT:8 12.03.2014 18:16 entnommen
   set toRun=robocopy "%S_DP%" "%T_DP%" /E /TBD /TEE /TIMFIX /R:4 /W:1 /MIR /LOG+:"%Log_DPNE%"
   Echo Start..........: %Date% %time%
   title Sync [from:%S_DP%] [to:%T_DP%]
   %toRun%
   Echo from Source Dir: "%S_DP%"
   Echo to Target Dir..: "%T_DP%"
   Echo End............: %Date% %time%
 :MyEnd

:eof

