If Not fs.FileExists( copyFile ) AND Not fs.FolderExists( copyFile ) Then fs.CopyFile originalFile, copyFile End If
DelOldestFile INFORM_DIR, BACKUP_CNT
Function FormatDateStamp(dt, format) format = Replace(format, "YYYY", Year(dt)) format = Replace(format, "YY", Right( Year(dt), 2 )) format = Replace(format, "MM", Right( Month(dt) + 100, 2 )) format = Replace(format, "M", Month(dt)) format = Replace(format, "DD", Right( Day(dt) + 100, 2 )) format = Replace(format, "D", Day(dt)) FormatDateStamp = format End Function
Function DelOldestFile(dir, limit) Dim dirObj, fileObj, delObj, fileCnt, oldDate Set dirObj = fs.GetFolder(dir) oldDate = Now() fileCnt = 0 For Each fileObj In dirObj.Files If Right(fileObj.Name, 4) = BACKUP_EXT Then If fileObj.DateCreated < oldDate Then oldDate = fileObj.DateCreated Set delObj = fileObj End If fileCnt = fileCnt + 1 End If Next
If fileCnt > limit Then delObj.Delete End If End Function