Compress Logs to Individual Archives using Command Line

Preface
A need to zip log files had arisen and needed to determine a solution. Winzip requires an installation of Winzip Command Line. If Winzip is unregistered, the application will prompt for acknowledgement to that fact. Tested several FREEWARE products, all require installation prior to use of command line or utilize proprietary compression.

Solution
Microsoft Compress.exe. It is FREEWARE, requires no installation, capable of tighter compression, quicker compression, and can be decompressed using Winzip. All tested with successful results.

I did some error checking. If the file (cab) already exists and so does the log file. This is as a result of log file in use. The following day, the log file should not be in use, and the (cab) will be replaced, with the log file being deleted.

Testing
I conducted the tests on IIS 6.0 log files ….\LogFiles\W3SVC1

Please note the file size differences in this example:
ex061017.log 293 KB
ex061017.log.cab 9 KB
ex061017.log.zip 10 KB

In this test, I re-extracted the log files and left the zip file in place for comparison. The above tests used LZX compression, the files were small enough.

compress.exe -zx I attempted same LZX compression on 512MB log files, the system 100% CPU, for minutes and incomplete.
compress.exe -z I utilized the MS-ZIP compression on 512 MB log files, the system 99% CPU, >2MB memory, and complete in 22 seconds.
wzzip.exe I compared the compress.exe MS-ZIP compression against winzip command line compression on same
512 MB log files, the system 99% CPU, ~4 MB memory, and complete in 22 seconds.
The compression ratio is negligable.

Conclusion
1. Copy compress.exe (Google it!) and compresslogs.cmd into log folder
2. Create Shedule Task after hours. (The first execution will take some time just to get caught up, daily executions should take 1-3 minutes).

Details
compresslogs.cmd

@echo off
for /F %%b in ('DIR *.log /b') do compress -z %%b %%b.cab
del *.log /q

Inspiration
I found a script on the internet script_442.zip and cannot find the original source.