Quick oldest item question

Started by MW4, July 28, 2016, 12:56:56 PM

Previous topic - Next topic

MW4

I an using this  function and would like to just get the oldest file (singular file)

#DefineFunction FileItemizeByDate(filemasks,option)
   ; Listing files by date
   ; Sort files by Y:M:D:H:M:S (date)
   ; Option @Ascending lists oldest to newest,@Descending lists newest to oldest
   arrFiles=FileInfoToArray(filemasks) ;retrieves unsorted list
   ; Remove header column
   ArrayRemove( arrFiles, 0, 1)
   ;Sort the array on the modified column
   ArraySort( arrFiles, option, 2 )
   ;Create a tabdelimited list of file names
   filelist = ''
   For xx = 0 To 0
      dafile =  arrFiles[xx,0]
      If filelist == "" Then filelist = dafile
      Else filelist = filelist:@TAB:dafile
   Next
   Return filelist
#EndFunction


DirChange('\\fleetdc01\Fleet\Miscellaneous\test\')
filelist = FileItemizeByDate('*.pdf',@ASCENDING) ; oldest to newest
result = AskItemlist("Files: oldest to newest", filelist, @TAB, @UNSORTED, @SINGLE )


Something like Message("oldest", (first item in filelist) )

Ideas?

td

Assuming you sort in ascending order, just return the file in the first row of the array.
"No one who sees a peregrine falcon fly can ever forget the beauty and thrill of that flight."
  - Dr. Tom Cade

MW4