@Echo off

set MyCmd_DPN=%~DPN0%

:Menu
color 70
Echo ---------------------------------------------------------------------------
Echo Delete Directory via RD /s /Q
Echo LastUpdate 17.05.2018  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 delete via rd /s /q
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 :DoDeleteDir "%~1" RUN
If "%~2" neq "" call :DoDeleteDir "%~2" RUN
If "%~3" neq "" call :DoDeleteDir "%~3" RUN
If "%~4" neq "" call :DoDeleteDir "%~4" RUN
If "%~5" neq "" call :DoDeleteDir "%~5" RUN
If "%~6" neq "" call :DoDeleteDir "%~6" RUN
If "%~7" neq "" call :DoDeleteDir "%~7" RUN
If "%~8" neq "" call :DoDeleteDir "%~8" RUN
 goto :eof
rem ----------------------------------------------------------------------------
:ListJobToDo
 If "%~1" neq "" call :DoDeleteDir "%~1" VIEW
 If "%~2" neq "" call :DoDeleteDir "%~2" VIEW
 If "%~3" neq "" call :DoDeleteDir "%~3" VIEW
 If "%~4" neq "" call :DoDeleteDir "%~4" VIEW
 If "%~5" neq "" call :DoDeleteDir "%~5" VIEW
 If "%~6" neq "" call :DoDeleteDir "%~6" VIEW
 If "%~7" neq "" call :DoDeleteDir "%~7" VIEW
 If "%~8" neq "" call :DoDeleteDir "%~8" VIEW
 goto :eof
rem ----------------------------------------------------------------------------


:DoDeleteDir

 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 Delete Dir.....: "%S_DP%"
 ) else (
   Echo Delete Dir.....: "%S_DP%"
 )


 if "%~2" neq "RUN" goto :MyEnd
   rem /MT:8 12.03.2014 18:16 entnommen
   set toRun=rd /s /q "%S_DP%"
   Echo Start..........: %Date% %time%
   title Delete [Dir:%S_DP%]
   %toRun%
   Echo End............: %Date% %time%
 :MyEnd

:eof

