I have a batch and a vbs file to zip a folder with a specific directory name and copy it to another folder.
How could I zip only the folder containing today's date? If it is not possible how could I zip only the folder having today's date as "Date Modified" column?
bat:
@echo off
set "mypath=C:\TEMP\zip\source\JEAR_20190115"
for /f %%i in ('dir /b /a-d "%mypath%"') do set "last=%%~ni"
CScript zip.vbs %mypath% C:\TEMP\zip\target\%last%.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
For example the following file is older than today so it shouldn't be zipped.
set "mypath=C:\TEMP\zip\source\JEAR_20190115"
If it would be equal to today's date the script should run:
set "mypath=C:\TEMP\zip\source\JEAR_20190117"
Previous question: https://stackoverflow.com/a/54216776/7420833