1

I'm trying to use VBScript to examine the contents of several hundred .zip files. Essentially what I want to do is run through each .zip and find all of the files wihtin that zip file. For each one of these files within the zip, I want to record some information about it to an Oracle database. That information being: file name and file modified date.

So far, my solution has been extracting each zips folder structure to a temp folder then running through the temp folder with an fso object. However, this has been proven to be very slow.

Is there a way to accoplish this without unziping the zip files?

user2276280
  • 603
  • 2
  • 10
  • 24
  • possible duplicate of [How to read the contents of a .zip file with VBScript without actually extracting the files?](http://stackoverflow.com/questions/4724140/how-to-read-the-contents-of-a-zip-file-with-vbscript-without-actually-extractin) – Helen Jan 19 '15 at 08:16

2 Answers2

0

Ouch man. I have never heard of vbscript zip object. But it has been a long time since I have done vbscript. Is there anyway you can avoid it?

I did some googling for you. I did find this: http://www.example-code.com/vbscript/zip_List.asp Chilkat has done a lot of stuff I thought not possible. This gives me the impression - that what you are trying to do is not going to be painless.

If given the problem you have I would find a different solution than vbscript. But if you pull-it-off I would vote for you to be mayor of vb land

terary
  • 940
  • 13
  • 30
  • Yeah, I'm not expecting it to be the easiest task. I've seen some other stackoverflow answers mention using command line "-l" to list the contents of the zip. But I'm not really sure exactly how that would work. – user2276280 Jan 16 '15 at 00:41
  • I use cygwin/bash instead of dos/command-line. It has a program that lists it content of zip. Its output is: "11805 08-26-2013 12:02 temp-bin/shutdown.exe". There is a line for each file. The name of the program is (wait for it...) 'unzip' . – terary Jan 16 '15 at 01:01
  • PKware developed zip files. Thay have command line utilities at https://www.pkware.com/software/pkzip/windows and (if on 32 bit windows) https://www.pkware.com/software/pkzip/dos – Serenity Jan 16 '15 at 02:02
0

You can do it in place with Shell Objects. But it will be just as slow, maybe. If just name and date Explorer may get it direct from the zip directory (at the end of the file so the whole file still needs to be read).

This copies items in a folder to another folder. A zip file is a folder so it will copy in and copy out.

To Zip

Set objShell = CreateObject("Shell.Application")
Set Ag=Wscript.Arguments
set WshShell = WScript.CreateObject("WScript.Shell")

Set SrcFldr=objShell.NameSpace(Ag(1))
Set DestFldr=objShell.NameSpace(Ag(0))
Set FldrItems=SrcFldr.Items
DestFldr.CopyHere FldrItems, &H214
Msgbox "Finished"

To Unzip (note SrcFolder and DestFolder are reversed)

Set objShell = CreateObject("Shell.Application")
Set Ag=Wscript.Arguments
set WshShell = WScript.CreateObject("WScript.Shell")

Set DestFldr=objShell.NameSpace(Ag(1))
Set SrcFldr=objShell.NameSpace(Ag(0))
Set FldrItems=SrcFldr.Items
DestFldr.CopyHere FldrItems, &H214
Msgbox "Finished"

To Create a blank zip. (I should have used an ADODB binary stream rather than an FSO text stream, but it shouldn't matter)

Set Ag=Wscript.Arguments
Set fso = CreateObject("Scripting.FileSystemObject")
Set ts = fso.OpenTextFile(Ag(0), 8, vbtrue)
BlankZip = "PK" & Chr(5) & Chr(6)
For x = 0 to 17
    BlankZip = BlankZip & Chr(0)
Next
ts.Write BlankZip
Serenity
  • 433
  • 2
  • 4