Spellings Consulting

When you need IT done right.

Zip Script

I was recently asked to zip up tens of thousands of files in a few hundred subdirectories.  The targeted files were those whose Last Modified date was older than one year ago.  Instead of manually zipping all of these files, I started looking for a way to automate this process.  I discovered that WinZip offers a Command Line Add-on, which would be accessible via script.  The Add-on does require the pruchase of WinZip 10 Pro, which I later discovered actually has similar features built-in already.

The Script
The script I’ve written is a VB Script that also utilizes the WinZip Command Line add-on mentioned above.  I have tested the script on: Windows 2000, Windows XP Pro, and Windows 2003 Server Standard Edition 64-Bit. 

After I wrote the script to use in a specific situation, I realized that it would be useful to alter it to be used in a more generic way.  So I added some features that allow the script to be called from the command line or a batch file in a manner where the user can add arguments when they call the script to control (1) the target directory (2) the Archive Date threshold (3) the file types to be zipped.

How it Works
The script goes through all the subdirectories in a directory and compares the Last Modified Date of each file to a date specified by the user.  If the Last Modified Date is older than the specified date, then the file is added to a zip file that is named the same name as the subdirectory.  If there is no existing zip file, then one is created.  After the files are added to the zip, they are removed from the subdirectory.

You can run the script as a scheduled task, but if you do, so be sure to alter the Default values for all of the variables that control how this script selects the target directory and files.  This is clearly commented in the code, so it should be easy to find.

The script also keeps a very detailed log file about what happens every time that it runs.  It can also be configured to send an email when it complete or fails.

If you would like a copy of this script, feel free to use it, but please give creidt to the author.  You can download it here.

No comments yet. Be the first.

Leave a reply