I recently posted a question on creating a batch file that would a) zip a folder structure & associated files and then b) move the .zip file into a specified directory.
Expert "chaau" provided an excellent solution. See http://www.experts-exchange.com/Programming/Languages/Scripting/Shell/Batch/Q_28294665.html#a39649505
for details. Also, code (developed by expert 'chaau' is provided below).
At this time, I need to slightly modify the script so that it would append a date-time-stamp (DTS) to the .zip file name.
For example, if the batch is executed on, e.g., March 20 @ 2:50 pm, I would like the filename to be as follows: "Test_2014_03_15_1450.zip"
. That said, the DTS "extension" must be dynamic (pulled from computer system time).
Note: If the date format will be different, that's fine as well. Primary goal is to be able to add the DTS after the "MPA" filename.
Is that doable? If yes, how should the code be modified to accommodate this task?
Const FOF_CREATEPROGRESSDLG = &H0&
Const MyZip = "c:\MyFolder\Test.zip"
Const File1 = "c:\Mainfolder_XYZ\"
'-------------- create empty zip file ---------
'Create the basis of a zip file.
.CreateTextFile(MyZip, True) _
.Write "PK" & Chr(5) & Chr(6) & String(18, vbNullChar)
'-------------- zip ---------------------------
'get ready to add files to zip
Set oShell = CreateObject("Shell.Application")
oShell.NameSpace(MyZip).CopyHere oShell.NameSpace(File1).Items, FOF_CREATEPROGRESSDLG
' Delete files from sub-folders
Dim fso, vfolder, subFlds, fld, file, vfolderContents
Set fso = CreateObject("Scripting.FileSystemObject")
Set vfolder = fso.GetFolder(File1)
Set subFlds = vfolder.SubFolders
For Each fld In subFlds
Set vfolderContents = fld.Files
For Each file In vfolderContents
Set vfolderContents = Nothing