OK. Check the new version with the group mask in the parameters:Peter wrote: 2022-12-14, 13:07 UTCmaybe a "wait until current file is done" could cause a better (and slower) execution?
Code: Select all
'————————————————————————————————————————————————————————————————
' Zip packaging of each file in the folder structure by file mask
' Condition: empty start path
' Parameters: <file mask>
' Example: name.ext;*.exe;*.txt
'————————————————————————————————————————————————————————————————
Option Explicit: Dim FSO, Shell, ZIP
If WSH.Arguments.Count = 0 Then MsgBox "Specify the mask as a parameter!", 4144: WSH.Quit
Set FSO = CreateObject("Scripting.FileSystemObject")
Set Shell = CreateObject("Shell.Application")
ZIP = "PK" & Chr(5) & Chr(6) & String(18, Chr(0))
Recursion FSO.GetAbsolutePathName("")
Set Shell = Nothing: Set FSO = Nothing
MsgBox " Done!", 262208, " Zip packaging by extension "
Sub Recursion(Dir)
Dim Items, File, Arch, Size, Sleep, Folder
Set Items = Shell.NameSpace(Dir).Items
Items.Filter 73920, WSH.Arguments(0)
If Items.Count Then
For Each File In Items
Arch = Dir & "\" & File.Name & ".zip"
With FSO.CreateTextFile(Arch, 1) .Write ZIP: .Close: End With
Size = File.Size: If Size < 786433 Then Sleep = 10 Else _
If Size < 3145728 Then Sleep = Fix(Size/78644) Else Sleep = 400
With Shell.NameSpace(Arch)
.CopyHere File, 13332
While .Items.Count = 0: WSH.Sleep Sleep: Wend
End With
FSO.DeleteFile File.Path, 1
Next
End If
For Each Folder In FSO.GetFolder(Dir).SubFolders
Recursion Folder.Path
Next
End Sub