@ECHO OFF
SET TIMESTAMP=%DATE%-%TIME%
SET TIMESTAMP=%TIMESTAMP: =0%
FOR %%F IN (log\error0.log.0 log\java0.log.0 log\error0.log log\java0.log log\stdout.log) DO IF EXIST %%F SET TIMESTAMP=%%~tF
SET PREFIX=%TIMESTAMP:~2,2%%TIMESTAMP:~5,2%%TIMESTAMP:~8,2%-%TIMESTAMP:~11,2%%TIMESTAMP:~14,2%

CALL :rotate.mv log\chat.log     "log\%PREFIX%_chat.log"
CALL :rotate.mv log\error0.log   "log\%PREFIX%_error0.log"
CALL :rotate.mv log\error0.log.0 "log\%PREFIX%_error.log"
CALL :rotate.mv log\gmaudit.log  "log\%PREFIX%_gmaudit.log"
CALL :rotate.mv log\item.log     "log\%PREFIX%_item.log"
CALL :rotate.mv log\java0.log    "log\%PREFIX%_java0.log"
CALL :rotate.mv log\java0.log.0  "log\%PREFIX%_java.log"
CALL :rotate.mv log\stdout.log   "log\%PREFIX%_stdout.log"
CALL :rotate.mv log\audit.log    "log\%PREFIX%_audit.log"
CALL :rotate.mv log\gmaudit.log  "log\%PREFIX%_gmaudit.log"

GOTO :EOF

:rotate.mv &@rem (source, destination) {
	IF NOT EXIST %1 EXIT /B
	IF "%~z1" == "0"  (DEL %1&EXIT /B)
	ECHO move %1 %2
	     move %1 %2
	EXIT /B
