Const ForReading = 1
Const ForWriting = 2
Const ForAppending = 8
strFolder = "c:\files"
strList = "filelist.txt"
strReport = "report.txt"
Set objOldFiles = CreateObject("Scripting.Dictionary")
objOldFiles.CompareMode = VbTextCompare
Set objFSO = CreateObject("Scripting.FileSystemObject")
If objFSO.FileExists(strReport) Then
objFSO.DeleteFile strReport, True
End If
If objFSO.FileExists(strList) Then
Set objList = objFSO.OpenTextFile(strList, ForReading)
Do Until objList.AtEndOfStream
arrLine = Split(objList.ReadLine, vbTab)
objOldFiles.Add arrLine(0), arrLine(1)
Loop
objList.Close
End If
Set objList = objFSO.OpenTextFile(strList, ForWriting, True)
Set objFolder = objFSO.GetFolder(strFolder)
For Each objFile In objFolder.Files
strName = objFile.Name
dtmCreated = objFile.DateCreated
objList.WriteLine strName & vbTab & dtmCreated
If Not objOldFiles.Exists(strName) Then
Set objReport = objFSO.OpenTextFile(strReport, ForAppending, True)
objReport.WriteLine strName & vbTab & dtmCreated
objReport.Close
End If
Next
|