Contents - Index


ZipFile (function)

ZipFile(sAction,sZipFile,sData) : sStatus 

Zipping/unzipping utilities often have a plethora of options that can be confusing. I have tried to keep the initial introduction of zip file support simple and to a bare minimum. Part of this simplicity means that folder recursion or multiple folder names are not supported (just files). More options/actions may be added in future releases.

sAction: The action to perform. Currently there a 3 supported actions

zip - Create a zip file. sZipFile is the name of the fully qualified zip file to create. If it already exists it will be overwritten completely. Sdata is the file(s) to be added to the zip file. Wild cards are supported, and multiple files can be added by separating each file with a ; (semi colon). The "sStatus" return value of this function is "OK" if everything went well or error text explaining the cause of the error. If there was an error, the error text will always begin with "*Error*"

unzip - Unzip a zip file. sZipFile is the name of the fully qualified zip file to unzip. Sdata is the fully qualified path where you want to unzip the files. All files in the archive will be unzipped, and any files with the same name in that folder will be overwritten. The "sStatus" return value of this function is "OK" if everything went well or error text explaining the cause of the error. If there was an error, the error text will always begin with "*Error*"

count - count the number of files inside a zip file. sZipFile is the name of the fully qualified zip file. Sdata is not used and should be passed as "". The "sStatus" return value of this function is the number of files (but as a string value) if everything went well or error text explaining the cause of the error. If there was an error, the error text will always begin with "*Error*"

To give you an idea of how to use this function I provide a macro that will effectively copy all the *.txt and *.gsk files from one folder to another.
 

# set the source, destination, and temp zip file
$Source = "c:\source"
$Destination = "c:\destination"
$TempZip = $_AppData + "\temp\temp.zip"

#create the zip file
$Status = ZipFile("zip",$TempZip,$Source + "\*.txt;" + $Source + "\*.gsk")

# error check
If left($Status,7) = "*Error*"
  Cancel Msg=$Status
EndIf

#unzip the files to the destination folder
$Status = ZipFile("unzip",$TempZip,$Destination)

# error check
If left($Status,7) = "*Error*"
  Cancel Msg=$Status
EndIf

# End with message showing number of files copied:
$Status = ZipFile("count",$TempZip,"")
MsgOk Msg=$Status Files copied

 
Alpha List         Category List