Hi, I'm looking for a short code that I can use in a task script for Enterprise. I would like it to make a zip-file of all file in one directory and then delete them. Anyone how some ideas?
Here is some vba code to do this. Perhaps this is helpful
Sub CreateZipFile() CreateEmptyZip "c:\testzip.zip" With CreateObject("Shell.Application") 'Add a file to the zip file .NameSpace("c:\testzip.zip").CopyHere "c:\ftpSLDocs.txt" 'This creates the folder in the zip file .NameSpace("c:\testzip.zip").CopyHere "c:\TestDirectory\" 'use this line if we want to zip all items in a folder into our zip file (but not the folder itself, just contents) .NameSpace("c:\testzip.zip").CopyHere .NameSpace("c:\TestDirectory\").items End WithEnd Sub
Public Sub CreateEmptyZip(sPath) Dim strZIPHeader As String ' header required to convince Windows shell that this is really a zip file strZIPHeader = Chr$(80) & Chr$(75) & Chr$(5) & Chr$(6) & String(18, 0) With CreateObject("Scripting.FileSystemObject") .CreateTextFile(sPath).Write strZIPHeader End WithEnd Sub
Retrieving data ...