I’m new to vbs, but I need to make a script that copies files from one folder to another, then reads a hole list of copied files and make a log file with those names. This is where I got it covered. Next thing I need to do is to make some sort of msgbox/IEmsg out of this list. This msgbox
should have all of the file names, line under the line, that script just copied.
This is my script:
StrMonth = Month(Date)
If Len(strMonth) = 1 Then
strMonth = "0" & strMonth
End If
StrDay = Day(Date)
If Len(strDay) = 1 Then
strDay = "0" & strDay
End If
StrYear = Year(Date)
FolderName = "c:\Rafel" & strDay & "." & strMonth & "." & StrYear
Set objFSO = CreateObject("Scripting.FileSystemObject")
SET objFolder = objFSO.CreateFolder(FolderName)
objFSO.CopyFile "c:\Rafel\files\*.*", FolderName & "\"
Wscript.Sleep 1000
IF objFSO.FileExists( FolderName & "\database.txt") THEN
Wscript.Echo "Folder created, files are copied."
END IF
SET objFSO = CreateObject("Scripting.FileSystemObject")
FILEFOLDER = FolderName
SET objFolder = objFSO.GetFolder(FILEFOLDER)
SET filelist = objFolder.Files
FILELOG = FolderName & "\file log.log"
FOR EACH objFile IN filelist
FILENAME = FILENAME & "###" & Now & " File copied" & "###" & vbCrlf &_
" File name:" & objFile.Name & vbCrlf &_
" Create date:" & objFile.DateLastModified & vbCrlf &_
" Size:" & objFile.Size & vbCrlf &_
vbCrlf
NEXT
SET objFile = objFSO.CreateTextFile(FILELOG)
objFile.Write vbCrlf
objFile.Write(FILENAME)
objFile.Close
As you can see, it works as far as making copies and creating log file with a list of files. But how can I make a one message box with a list of those files? I’ve tried, for each
but it just “spam” msgbox for each file.
I'm a noob so pls take that in mind. :)