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
Not my original idea, the inspiration is from: