The following code is, I think, close (it only is supposed to list the files, not delete them at this point) but the calculation of the difference between the current date and the file date isn't working. It lists all files with their last written dates, not just the ones older than 3 days. I'm sure it's something really simple and quite obvious but I just don't see (logically or syntactically) what I'm doing wrong.
Any guidance or comments greatly appreciated.
Thanks in advance.
Tom
Code: Select all
Directory$ = "c:\asmwork"
Today = Date()
Debug "Today's date is " + FormatDate("%yyyy.%mm.%dd", Date())
Debug "Three days ago the date was " + FormatDate("%yyyy.%mm.%dd", AddDate(Date(), #PB_Date_Day, -3))
If ExamineDirectory(0, Directory$,"*.asm")
While NextDirectoryEntry(0)
If DirectoryEntryType(0) = #PB_DirectoryEntry_File
Result = GetFileDate(DirectoryEntryName(0), #PB_Date_Modified)
FDate = AddDate(Date(), #PB_Date_Day, -3)
If (Result < FDate)
Debug DirectoryEntryName(0) + " last modified " + FormatDate("%yyyy.%mm.%dd", Result)
EndIf
EndIf
Wend
EndIf