VBScript expert I am not. I can use other peoples work to build what I want, but this one I'm having problems with....
Using VBScript, I need to compare the 2 most recent files in a folder, and if they are different, set an error code that I can pass to the calling program. New files will be transferred every 10 minutes and as part of the process I need to compare the files so the user can process the new data if it exists. At the start of the day, it will compare between the new file and a static blank file to see if data has been added. The file names will be in the format filename-mmddyyyy-hhmmssss.csv
I've found a ton of information, but nothing specifically doing what I'm looking for.
Thanks for any and all help!
Edit: Gotten closer to what I'm looking for....
'Delete files from previous run Set objFSO = CreateObject("Scripting.FileSystemObject") objStartFolder = "L:\Inbox\Test\"
Set objFolder = objFSO.GetFolder(objStartFolder)
Set colFiles = objFolder.Files For Each objFile in colFiles if instr(objFile.Name,".csv") then objFSO.DeleteFile "L:\Inbox\Test*.*" end if Next
'Copy the newest 2 files to the tesing folder src = "L:\Inbox" dst = "L:\Inbox\Test"
Set fso = CreateObject("Scripting.FileSystemObject")
mostRecent = Array(Nothing, Nothing)
For Each f In fso.GetFolder(src).Files If LCase(fso.GetExtensionName(f.Name)) = "csv" Then If mostRecent(0) Is Nothing Then Set mostRecent(0) = f ElseIf f.DateLastModified > mostRecent(0).DateLastModified Then Set mostRecent(1) = mostRecent(0) Set mostRecent(0) = f ElseIf mostRecent(1) Is Nothing Or f.DateLastModified > mostRecent(1).DateLastModified Then Set mostRecent(1) = f End If End If Next
For i = 0 To 1 If Not mostRecent(i) Is Nothing Then mostRecent(i).Copy dst & "\" Next
'Compare the 2 files in L:\Inbox\Test and set an errorlevel
***** This is the next part to figure out *****