There was a task to compress all the log files for a Microsoft IIS6 installation. The log files were taking up gigabytes of space, whereas a single log file may be as large as 50 to 100MB in size. A compressed log file resulted in only 2-4MB in size. I needed a method that would compress each log file into it’s own individual zip file.
To do so, I created a command (CMD) or batch file (BAT) with these two lines of code. The code will read through a directory for each file with a log extension and use the command line version of WinZip to move the log into it’s own zip. This is a simple script. More complex scripts, may offer error handling or other compression applications may be used in WinZip’s place. I have tested and used 7zip with success as well using it’s own command line structure, of course.
@echo off for /F %%b in ('DIR *.log /b') do wzzip -m %%b.zip %%b