Created
October 12, 2021 04:40
-
-
Save pinei/d86d558c55471a53d66985f4b5ba5fd3 to your computer and use it in GitHub Desktop.
Zip a folder with Windows command-line or .bat
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Set fso = CreateObject("Scripting.FileSystemObject") | |
| InputFolder = fso.GetAbsolutePathName(WScript.Arguments.Item(0)) | |
| ZipFile = fso.GetAbsolutePathName(WScript.Arguments.Item(1)) | |
| ' Create empty ZIP file. | |
| CreateObject("Scripting.FileSystemObject").CreateTextFile(ZipFile, True).Write "PK" & Chr(5) & Chr(6) & String(18, vbNullChar) | |
| Set objShell = CreateObject("Shell.Application") | |
| Set source = objShell.NameSpace(InputFolder).Items | |
| objShell.NameSpace(ZipFile).CopyHere(source) | |
| ' Keep script waiting until compression is done | |
| Do Until objShell.NameSpace( ZipFile ).Items.Count = objShell.NameSpace( InputFolder ).Items.Count | |
| WScript.Sleep 200 | |
| Loop |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment