I have a batch and a vbs file to zip a folder with a specific directory name and copy it to another folder.
Does anyone have a clue how to zip a folder with the name of its content (filename) expanding the existing script I have?
With the following two scripts I can make the directories to be zipped and copied to another folder.
bat:
CScript zip.vbs C:\TEMP\zip\source\JEAR_20190115 C:\TEMP\zip\target\JEAR.zip
vbs:
'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
Running the batch file which calls the vbs the folder's content (3 files) are zipped and copied to the target directory described in the bat file (C:\TEMP\zip\target\JEAR.zip).
The output filename is specified in the bat file but the goal is to have the filename of the zipped folder's content (filename). Which is JEAR_20180116.*