This is a very simple VBScript that will zip all files and folders within a specified folder. This script is useful if you want to automate the task of zipping multiple files to create an archive. You can comment out the folders section of the script if you only want to zip files.
Option Explicit
WScript.Echo "You have begun the ZipLogFiles process. Press the OK button to begin."
Dim objFile, objPath, objFolder, Command, PathLogs, RetVal
Dim objFSO: Set objFSO = CreateObject("Scripting.FileSystemObject")
Dim objShell: Set objShell = CreateObject("WScript.Shell")
PathLogs = "C:\Temp\"
' Loop through the logs and zip and move each file (if required, you could just move files with an '.log' extension)
Set objPath = objFSO.GetFolder(PathLogs)
For Each objFile In objPath.Files
If (LCase(objfso.GetExtensionName(objFile)) "zip") Then
'Wscript.Echo objFile.Name
' zip and move files
Command = """C:\Program Files\WinZip\winzip32.exe"" -m -ex """ & PathLogs & objfso.GetBaseName(objFile) & ".zip"" """ & PathLogs & objFile.Name & """"
RetVal = objShell.Run(Command,0,true)
'WScript.Echo "Command: " & Command
End If
Next
For Each objFolder In objPath.SubFolders
'WScript.Echo objFolder.Name
' zip and move folders
Command = """C:\Program Files\WinZip\winzip32.exe"" -m -r -ex """ & PathLogs & objFolder.Name & ".zip"" """ & PathLogs & objFolder.Name & "\"""
RetVal = objShell.Run(Command,0,true)
'WScript.Echo "Command: " & Command
Next
WScript.Echo "Script has ended."