Hi Dustin!
Quote:
Originally Posted by DHaralson
Any help you can give me would be greatly appreciated. Thanks!
Dustin
|
You can get the function you are looking for by using a small vbscript that will loop through the folders looking for the specified fileextensions. This is a workaround for the problem that filename like *.jpg won't work when using the recursive parameter.
The script is this:
Code:
'***********************************************************
'* PACOMP.vbs
'* @author: Micke
'*
'* Script for compress multiple file types
'*
'* Usage: cscript PACOMP.vbs ArhiveName.extension DrivePath
'* Example1: cscript PACOMP.vbs MyArchive.zip D:
'* Example2: cscript PACOMP.vbs MyArchive.zip D:\Temp
'*
'***********************************************************
Option Explicit
'Variables
Dim FSO, objDir, aList, FileExtension, ArchiveName, DrivePath
Dim aFile, aItem, strCompressionString, WshShell
'Constants (Change path to your own enviroment)
Const PACOMP = "C:\Programs\PACL\PACOMP.exe"
'Check number of arguments
If WScript.Arguments.Count <> 2 Then
WScript.Echo "Usage: cscript PACOMP.vbs ArchiveName.extension DrivePath"
WScript.Echo "Example 1: cscript PACOMP.vbs MyArchive.zip D:"
WScript.Echo "Example 2: cscript PACOMP.vbs MyArchive.zip D:\Temp"
WScript.Quit
End If
'Create the FileSystemObject
Set FSO = CreateObject("Scripting.FileSystemObject")
'Create the ShellObject
Set WshShell = CreateObject("WScript.Shell")
'Get data from the Arguments
ArchiveName = WScript.Arguments.Item(0)
DrivePath = WScript.Arguments.Item(1)
'Get the Folders for the DrivePath
Set objDir = FSO.GetFolder(DrivePath)
'Create a Array with Fileextensions for the archive, change to your enviroment
aList = Array("png", "jpg", "avi")
'Search through the folders
SearchFolders(objDir)
'Sub for Searching recursive in Folders
Sub SearchFolders(pstrCurrentPath)
For Each aFile In pstrCurrentPath.Files
For Each FileExtension In aList
If FileExtension = LCase(Right(CStr(aFile.Name), 3)) Then
AddFileToArchive aFile.Path
End If
Next
Next
For Each aItem In pstrCurrentPath.SubFolders
SearchFolders(aItem)
Next
End Sub
Sub AddFileToArchive(pstrFileName)
'Create the string with parameters for PACOMP
strCompressionString = PACOMP & " -a -P " & ArchiveName & " " & pstrFileName
WScript.Echo strCompressionString
WshShell.Run strCompressionString, 0, True
End Sub
You can also downloading the script here:
PACOMP_Script.zip
There are two lines in the script you have to modify for your own enviroment.
Change this to your path for PACOMP
Code:
Const PACOMP = "C:\Programs\PACL\PACOMP.exe"
Add more FileExtension for your Archive. I have tested it with these 3 and it works as expected.
Code:
aList = Array("png", "jpg", "avi")
The script is only tested on Windows XP with SP3. Hope that it will work for you.
Kind Regards
Micke