Here is the quick script to compress *.log file with 7zip.

 

You may want to change PATH and DAYS (which is 45 here) and create schedule task for it.

@echo off
setlocal EnableExtensions DisableDelayedExpansion

rem // Define constants here:
set “_ROOT=C:\Path\W3SVC1”
set “_PATTERN=*.log”
set “_LIST=%TEMP%\%~n0.tmp”
set “_ARCHIVER=%ProgramFiles%\7-Zip\7z.exe”

rem // Get current date in locale-independent format:
for /F “tokens=2 delims==” %%D in (‘wmic OS get LocalDateTime /VALUE’) do set “TDATE=%%D”
set “TDATE=%TDATE:~,8%”

rem // Create a list file containing all files to move to the archive:
> “%_LIST%” (
for /F “delims=” %%F in (‘
forfiles /S /P “%_ROOT%” /M “%_PATTERN%” /D -45 /C “cmd /C echo @path”
‘) do echo(%%~F
) && (
rem // Archive all listed files at once and delete the processed files finally:
“%_ARCHIVER%” a -sdel “%_ROOT%_%TDATE%.zip” @”%_LIST%”
rem // Delete the list file:
del “%_LIST%”
)

endlocal
exit /B