Does anyone have a method of zipping more than one file into one compressed
file? I am trying to combine several report files into one so I can then
execute command line switches for Outlook to schedule emails. I have the
command line working but Outllok will not attach more than one file with this
method.

Any other ideas?

Thank in advance
--
Jeff C
Live Well .. Be Happy In All You Do

Re: Zip a file by Paul

Paul
Thu Mar 20 21:16:13 CDT 2008


"Jeff C" <JeffC@discussions.microsoft.com> wrote in message
news:B16EFC9B-9A5F-4070-B95E-0E6F157C7CF3@microsoft.com...
> Does anyone have a method of zipping more than one file into one
> compressed
> file? I am trying to combine several report files into one so I can
> then
> execute command line switches for Outlook to schedule emails. I
> have the
> command line working but Outllok will not attach more than one file
> with this
> method.
>
> Any other ideas?
>
> Thank in advance
> --
> Jeff C
> Live Well .. Be Happy In All You Do

I have been working on a set of routines to create a .zip file and add
files/folders to it, but this is still a work in progress. Back in
the days of the DOS days of PKZip, I had a number of batch files for
creating and adding to zip files, and I understood the overhead
associated with adding things to or deleting things from a zip file;
there was a lot of overhead with modifying large zip files, so I
worked hard to set it up to create the zip file with one pkzip
command.

The zip process I currently use is a combination of ideas from a
number of posts. It sets up an empty .zip file by writing 31 bytes to
a file with a .zip extension. It then sets up a shell.application
folder object for that .zip destination file, using the
shell.application's Namespace method.

I manually copy all the files/folders I intend to put into that .zip
file into a single source folder. The script creates a
shell.application folder object for this source folder.

The script uses the zip file's shell.application folder object's
CopyHere method to copy all the source shell.application folder's
items. This spawns a separate process that does the actual
copying/zipping, and I don't know of any 'copy/zip done' event to
indicate completion. Depending on things I haven't investigated,
there may be user prompts or a progress window.

The script then monitors the count of items in the zip file's
shell.application folder object. When that count matches the items
count for the source shell.application folder object, the script
assumes the process must be complete. The script doesn't have a
timeout exit if the count is never reached.

I think you could add to an existing .zip file using this process, but
you would have to make adjustments for item count. I have not
investigated how much overhead is involved with adding files to a
large existing .zip file. I don't know what happens with file/folder
name collisions in the destination .zip file. I think you can filter
the items collection with wildcards, so that only a subset of items
from the source folder is put into the zip file. I think the source
folder can be a 'search' result folder, so you might be able to zip a
collection of stuff from a number of source folders with one CopyHere.

If you want to play with this work in progress, here it is:

'Script to demo zipping all the files in a specified folder into a new
' .Zip file
'Note: This demo does NOT have a direct method of monitoring progress.
'The Shell Folder's CopyHere method starts an external process to
' do the actual copying; depending on options set, it may provide
' popup windows to show progress, ask what to do about
' collisions, etc. This external process does not show up in Task
' Manager.
' Note that any progress or other popup windows take focus away
' from whatever the user may be doing, or from other windows
' to which scripts may be sending keystrokes through the use
' of things like SendKeys or AutoIt.
'This script overwrites the specified .Zip file, creating a new one,
' thus ensuring that completion can be assumed when the number of
' items in the .Zip file matches the number of items in the source
' folder.
Option Explicit
Dim TimeStart
MsgBox "Starting"
Dim sFolderPath: sFolderPath = "H:\ZipTest"
Dim sFullZipPath
sFullZipPath = "C:\Documents and Settings\Paul\My
Documents\vbScript\ZipTest\dummy2.zip"
Dim objFSO
Set objFSO = CreateObject("Scripting.FileSystemObject")
If Not objFSO.FileExists(sFullZipPath) Then
With CreateObject("Scripting.FileSystemObject")
.CreateTextFile(sFullZipPath, True, False).Write("")
End With
End If
Dim oShellApp
Set oShellApp = CreateObject("Shell.Application")
MsgBox "Prior to creating/overwriting the current Zip file:" & vbCrLf
& _
"sFullZipPath Count = " & oShellApp.NameSpace _
(sFullZipPath).Items.Count & vbCrLf & _
"sFolderPath Count = " & oShellApp.NameSpace _
(sFolderPath).Items.Count
TimeStart = Now

' Create an empty ZIP file
CreateMTZip sFullZipPath

' Copy all files from sFolderPath into the ZIP file
oShellApp.NameSpace(sFullZipPath).CopyHere _
oShellApp.NameSpace(sFolderPath).Items
' Keep script waiting until compression is done
'WScript.Sleep 1000
On Error Resume Next
Do Until oShellApp.NameSpace(sFullZipPath).Items.Count _
= oShellApp.NameSpace(sFolderPath).Items.Count
WScript.Sleep 200
Loop
On Error Goto 0
MsgBox "Elapsed time: " & DateDiff("s", TimeStart, Now) & _
" Seconds" & vbCrLf & _
"After creating/overwriting the current Zip file:" & vbCrLf & _
"sFullZipPath Count = " & oShellApp.NameSpace _
(sFullZipPath).Items.Count & vbCrLf & _
"sFolderPath Count = " & oShellApp.NameSpace _
(sFolderPath).Items.Count


Function CreateMTZip(sZipPath)
'Creates OR overwrites the file sZipPath, with a binary string
' that represents the contents of an empty .Zip file/folder.
'If the file name's extension is .zip, then WXPSP2 (and perhaps
' other Windows versions) will treat this file as an empty
' compressed folder.
Dim sBinary 'String equivalent of empty .Zip file/folder.
sBinary = "PK" & Chr(5) & Chr(6) & String(18, 0)
With CreateObject("Scripting.FileSystemObject")
.CreateTextFile(sZipPath, True, False).Write(sBinary)
End With
End Function 'CreateMTZip(sZipPath)

-Paul Randall


begin 666 Zip.vbs
M)U-C<FEP="!T;R!D96UO('II<'!I;F<@86QL('1H92!F:6QE<R!I;B!A('-P
M96-I9FEE9"!F;VQD97(@:6YT;R!A(&YE=PT*)PDN6FEP(&9I;&4-"B=.;W1E
M.B!4:&ES(&1E;6\@9&]E<R!.3U0@:&%V92!A(&1I<F5C="!M971H;V0@;V8@
M;6]N:71O<FEN9R!P<F]G<F5S<RX-"B=4:&4@4VAE;&P@1F]L9&5R)W,@0V]P
M>4AE<F4@;65T:&]D('-T87)T<R!A;B!E>'1E<FYA;"!P<F]C97-S('1O#0HG
M"61O('1H92!A8W1U86P@8V]P>6EN9SL@9&5P96YD:6YG(&]N(&]P=&EO;G,@
M<V5T+"!I="!M87D@<')O=FED90T*)PEP;W!U<"!W:6YD;W=S('1O('-H;W<@
M<')O9W)E<W,L(&%S:R!W:&%T('1O(&1O(&%B;W5T#0HG"6-O;&QI<VEO;G,L
M(&5T8RX@(%1H:7,@97AT97)N86P@<')O8V5S<R!D;V5S(&YO="!S:&]W('5P
M(&EN(%1A<VL-"B<)36%N86=E<BX-"B<)3F]T92!T:&%T(&%N>2!P<F]G<F5S
M<R!O<B!O=&AE<B!P;W!U<"!W:6YD;W=S('1A:V4@9F]C=7,@87=A>0T*)PD)
M9G)O;2!W:&%T979E<B!T:&4@=7-E<B!M87D@8F4@9&]I;F<L(&]R(&9R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<GDI#0I%;F0@5VET: T*16YD($9U;F-T:6]N"2=#<F5A=&5-5%II<"AS
(6FEP4&%T:"D`
`
end


Re: Zip a file by Tim

Tim
Thu Mar 20 21:19:13 CDT 2008

You might try this:
http://www.rondebruin.nl/windowsxpzip.htm

Tim


"Jeff C" <JeffC@discussions.microsoft.com> wrote in message
news:B16EFC9B-9A5F-4070-B95E-0E6F157C7CF3@microsoft.com...
> Does anyone have a method of zipping more than one file into one
> compressed
> file? I am trying to combine several report files into one so I can then
> execute command line switches for Outlook to schedule emails. I have the
> command line working but Outllok will not attach more than one file with
> this
> method.
>
> Any other ideas?
>
> Thank in advance
> --
> Jeff C
> Live Well .. Be Happy In All You Do



Re: Zip a file by James

James
Fri Mar 21 13:45:14 CDT 2008

"Jeff C" <JeffC@discussions.microsoft.com> wrote in message
news:B16EFC9B-9A5F-4070-B95E-0E6F157C7CF3@microsoft.com...
> Does anyone have a method of zipping more than one file into one
> compressed
> file? I am trying to combine several report files into one so I can then
> execute command line switches for Outlook to schedule emails. I have the
> command line working but Outllok will not attach more than one file with
> this
> method.
>
> Any other ideas?

Jeff, my suggestion would be to use the cabarc.exe command line utility from
Microsoft to create a cabinet archive of your reports. Cabarc is a free
download from Microsoft. You can get it inside the very small (463KB)
'Microsoft Cabinet SDK' at http://support.microsoft.com/kb/310618. There is
a newer version (not sure of the difference) inside the 'Windows XP Service
Pack 2 Support Tools'. The download is larger (4.7 MB), but the version is 4
years newer. In both cases, if you have WinZIP or WinRAR on your computer,
you can extract cabarc.exe without needing to install anything or actually
execute the downloaded file. The 'Windows XP Service Pack 2 Support Tools'
can be found at (watch for wrapping):

http://microsoft.com/downloads/details.aspx?familyid=49ae8576-9bb9-4126-9761-ba8011fabf38

Cabinet files offer several advantages over zip files with a few small
disadvantages. The compression is much better (when using LZX), the utility
is free & cabinet archives are supported natively in Windows from Windows
98 - Windows Vista. If you have WinZIP installed with it's default options,
cabinet archives will appear and work like zip files. The disadvantages are
that cabinet compression is much slower than zip (but on small documents you
would probably not notice it) and the archives are solid, so you cannot
simply add or remove files from an existing archive. You have to extract it
and then recreate the archive with your changes.

To compress your files, you can put cabarc.exe (cabinet.dll might also be
required) in the %path% of the directory with your script. Something like
this should work:

'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Dim oWSH, sSrcDir, sArchive

sSrcDir = "C:\Documents to compress"
sArchive = "C:\Archive.cab"

Set oWSH = CreateObject("WScript.Shell")

If Not Right(sSrcDir, 1) = "\" Then sSrcDir = sSrcDir & "\"

oWSH.Run "cabarc.exe N """ & sArchive & """ """ & sSrcDir & "\*.*", 0, True
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~




Re: Zip a file by noone

noone
Sat Mar 29 08:24:36 CDT 2008

Il giorno Thu, 20 Mar 2008 16:37:00 -0700, =?Utf-8?B?SmVmZiBD?=
<JeffC@discussions.microsoft.com> ha scritto:
>Does anyone have a method of zipping more than one file into one compressed
>file? I am trying to combine several report files into one so I can then
>execute command line switches for Outlook to schedule emails. I have the
>command line working but Outllok will not attach more than one file with this
>method.


Function AddFile2Zip (sZipFile, sFile2Add)
'sZipFile must exist
'sZipFile must be a complete pathname (required by Namespace method)
'Aggiunge un file all'archivio zip esistente.
'Attenzione: di default il metodo CopyFile sovrascrive.
'NameSpace vuole un pathname completo e non solo il nome file.
On Error Resume Next
AddFile2Zip = True
Set oApp = createobject("Shell.Application")
oApp.NameSpace(sZipFile).CopyHere sFile2Add
If Err<>0 Then AddFile2Zip=False
End Function

This creates an empty zipfile
Function CreateEmptyZip(sPathName)
'Create empty Zip File.
'Crea un file zip vuoto.
Dim fso, fp
Const ForWriting = 2 'Apre un file in scrittura.
CreateEmptyZip = True 'se tutto va bene resta true.
On Error Resume Next
Set fso = CreateObject("Scripting.FileSystemObject")
Set fp = fso.OpenTextFile( sPathName, ForWriting, True )
If Err <> 0 Then
Set opfs = Nothing
CreateEmptyZip=False
Exit Function 'Errore nella creazione
end if
fp.Write Chr(80) & Chr(75) & Chr(5) & Chr(6) & String(18, 0)
If Err <> 0 Then
Set opfs = Nothing
CreateEmptyZip=False
Exit Function 'errore nella scrittura
End If
fp.Close 'Chiude il file, altrimenti non si può usare.
Set fso = Nothing
Err.Clear
End Function
--
Giovanni Cenati (Bergamo, Italy)
Write to user "Reventlov" and domain at katamail com
http://digilander.libero.it/Cenati (Esempi e programmi in VbScript)
--