我正在尝试使用 VBScript 来检查数百个 .zip 文件的内容。基本上我想要做的是遍历每个 .zip 并找到该 zip 文件中的所有文件。对于 zip 中的这些文件中的每一个,我都想将有关它的一些信息记录到 Oracle 数据库中。该信息是:文件名和文件修改日期。
到目前为止,我的解决方案是将每个 zips 文件夹结构提取到一个临时文件夹,然后使用 fso 对象运行该临时文件夹。然而,这已被证明是非常缓慢的。
有没有办法在不解压缩 zip 文件的情况下实现这一点?
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
您可以使用壳对象来完成它。但它可能会同样缓慢。如果只是名称和日期,资源管理器可能会直接从 zip 目录中获取它(在文件末尾,因此仍然需要读取整个文件)。
这会将文件夹中的项目复制到另一个文件夹。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"
解压(注意 SrcFolder 和 DestFolder 是相反的)
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"
创建一个空白拉链。(我应该使用 ADODB 二进制流而不是 FSO 文本流,但这没关系)
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