限制 zip 文件大小 [英] Limiting zip file size
问题描述
我在 VBScript 中有一个脚本,用于获取文件夹的内容并将其放入 zip 文件中.它主要基于我在另一篇文章中发现的内容,因为我不是 VBS 专家.这是功能:
I have a script in VBScript that gets the content of a folder and gets it into a zip. It is mainly based on what I found in another post, as I am no VBS expert. This is the function:
Sub ArchiveFolder (zipFile, sFolder)
With CreateObject("Scripting.FileSystemObject")
zipFile = .GetAbsolutePathName(zipFile)
sFolder = .GetAbsolutePathName(sFolder)
With .CreateTextFile(zipFile, True)
.Write Chr(80) & Chr(75) & Chr(5) & Chr(6) & String(18, chr(0))
End With
End With
With CreateObject("Shell.Application")
.NameSpace(zipFile).CopyHere .NameSpace(sFolder).Items
Do Until .NameSpace(zipFile).Items.Count = _
.NameSpace(sFolder).Items.Count
WScript.Sleep 1000
Loop
End With
End Sub
我需要将生成的文件分成大小受限的文件 (80MB).有没有办法做到这一点?
I need to divide the resulting file in size limited files (80MB). Is there a way to do this?
据我所知,Chr(80) &Chr(75) &Chr(5) &Chr(6) &String(18, chr(0))
部分指示创建一个 zip 文件,但我无法找到这意味着什么以及如何参数化操作的解释.
As I understand it, the Chr(80) & Chr(75) & Chr(5) & Chr(6) & String(18, chr(0))
part is indicating to create a zip file, but I am not able to find an explanation of what this means and how to parametrize the action.
推荐答案
我终于用7zip的便携版解决了.在那里我可以使用我需要的参数创建 zip 文件:
I have finally solved it by using 7zip's portable version. There I can create the zip file with the parameters I need:
Set oShell = CreateObject("WScript.Shell")
strCmd = "7-Zip\7z.exe a -v80m " & zipFile & " " & sFolder
oShell.Run(strCmd)
Set oShell = Nothing
这篇关于限制 zip 文件大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!