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
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
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
You could use a 3rd party tool, I suggest 7-Zip, which has a command line version you can use in batch.
See here for a list of usable commands and examples.
Here you can find two ways without using any external tools .
Better use the WSH/Jscript script that uses the Shell.Application object.