Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to compress in a batch file

I have a problem about compressing a directory or a file in a batch file. HOw can I do this, Can anybody help me about this?

Thank you

like image 490
eponymous Avatar asked Oct 23 '22 19:10

eponymous


1 Answers

There is a good solution to a similar question on a Post on SuperUser, I have copy pasted it below.

CScript zip.vbs C:\test3 C:\someArchive.zip

Where zip.vbs contains the following

'Get command-line arguments.
Set objArgs = WScript.Arguments
InputFolder = objArgs(0)
ZipFile = objArgs(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)

'Required!
wScript.Sleep 2000
like image 154
John Mitchell Avatar answered Oct 26 '22 23:10

John Mitchell