set PATH_DIR=C:\Program Files\stunnel\ set LOGSUFFX=%date:~0,2%-%date:~3,2%-%date:~6,4% set NEWSTU=stunnel-%LOGSUFFX%.log Net stop stunnel @ping 127.0.0.1 -n 10 >NUL rename "%PATH_DIR%stunnel.log" %NEWSTU% move "%PATH_DIR%%NEWSTU%" "%PATH_DIR%logs\%NEWSTU%" Net start stunnel