@echo off
set SINBINDIR=Release

if not defined SINDIR ( goto failedsindir )
if not defined SEVENZIPPATH ( goto failed7zpath )

:startcopy
echo Copying %SINBINDIR% Build.

ERRTIME -y > NUL

FOR %%A IN (0 1 2 3 4 5 6 7 8 9) DO IF ERRORLEVEL %%A0 SET ERR10=%%A
FOR %%A IN (0 1 2 3 4 5 6 7 8 9) DO IF ERRORLEVEL %ERR10%%%A SET ERR1=%%A
SET YEAR=%ERR10%%ERR1%

ERRTIME -m > NUL

FOR %%A IN (0 1 2 3 4 5 6 7 8 9) DO IF ERRORLEVEL %%A0 SET ERR10=%%A
FOR %%A IN (0 1 2 3 4 5 6 7 8 9) DO IF ERRORLEVEL %ERR10%%%A SET ERR1=%%A
SET MONTH=%ERR10%%ERR1%

ERRTIME -d > NUL

FOR %%A IN (0 1 2 3 4 5 6 7 8 9) DO IF ERRORLEVEL %%A0 SET ERR10=%%A
FOR %%A IN (0 1 2 3 4 5 6 7 8 9) DO IF ERRORLEVEL %ERR10%%%A SET ERR1=%%A
SET DAY=%ERR10%%ERR1%

md "..\_build"
md "..\_build\base"
md "..\_build\ctf"
md "..\_build\2015"

copy /Y ..\%SINBINDIR%\x64\sin_x64.exe "..\_build"
copy /y ..\%SINBINDIR%\x64\sinded_x64.exe "..\_build"
copy /Y ..\%SINBINDIR%\x64\ref_soft.dll "..\_build"
copy /Y ..\%SINBINDIR%\x64\ref_gl.dll "..\_build"
copy /Y ..\readme.txt "..\_build"
copy /Y ..\%SINBINDIR%\x64\base\gamex64.dll "..\_build\base"
copy /Y ..\%SINBINDIR%\x64\base\gamex64.dll "..\_build\ctf"
copy /Y ..\%SINBINDIR%\x64\2015\gamex64.dll "..\_build\2015"

"%SEVENZIPPATH%\7z.exe" a -mx9 -mmt "..\sin_20%YEAR%%MONTH%%DAY%_win64.7z" "..\_build\*"
rd /s /q "..\_build"

goto end

:failedsindir
echo SINDIR not defined!
pause
goto end

:failed7zpath
echo SEVENZIPPATH not defined!
pause
goto end

:end
set SINBINDIR=
