@echo off

:: Extract the date and apply it to variables.
for /F "tokens=1-4 delims=/ " %%i in ('date /t') do (
    set DayOfWeek=%%i
    set Month=%%j
    set Year=%%k
)

SET SUN4LOCATION=T:\
SET SUN4COPY=C:\SUN4COPY

:menu
cls
echo.
echo Select an option by pressing the associated number
echo ==================================================
echo.
echo.
echo [1] Backup SUN4 files on %SUN4LOCATION% to %SUN4COPY%
echo.
echo.
echo [2] Restore backup SUN4 files from %SUN4COPY% to %SUN4LOCATION%
echo.
echo.
echo [3] Exit
echo.
echo.
c:\mrc\choice.com /C:123

if errorlevel=3 goto end
if errorlevel=2 goto restoresun4
if errorlevel=1 goto backupsun4


:backupsun4

:if not exist "C:\Program Files\ZipGenius 6\zg.exe" goto installzg

:startcopy
cls
echo The SUN4 files from %SUN4LOCATION% will now be copied to %SUN4COPY%
echo.
echo This may take a few minutes...
echo.
sleep 10
cls
robocopy %SUN4LOCATION% %SUN4COPY% /e /z /r:3 /w:5 /mir

:"C:\Program Files\ZipGenius 6\zg.exe" -add C:\SUN4_%DayOfWeek%-%Month%-%Year%.zip CB R1 F2 +"%SUN4COPY%\*.*"

cls
echo Please wait a few moments...

attrib +H %SUN4COPY% /S /D

cls
echo The SUN4 files have been copied to %SUN4COPY%
echo.
echo Re-run this program if you need to restore the files !!
echo.
sleep 10

goto end

:restoresun4
cls
echo The SUN4 files from will now be restored from %SUN4COPY%
echo.
echo This may take a few minutes...
echo.
sleep 10
cls
robocopy %SUN4COPY% %SUN4LOCATION% /e /z /r:3 /w:5 /mir

goto end

:end
exit


:installzg
net use z: \\SU3200\install$ /persistent:no
start /wait z:\ZipGenius\zipgenius.exe /verysilent
net use z: /delete
goto startcopy