6 Replies Latest reply: Oct 26, 2016 8:20 AM by David Young RSS

    How to get the Max Date Modified in a folder

    David Young

      Is there a way to get the Max Date Modified in a folder.  I have the following folder location:




      In that folder I have a bunch of back files that look like this:


      Name                                                                      Date Modified

      backup_F_Gates_160214_0006.dist                          2/14/2016

      backup_F_Gates_160212_0008.dist                          5/15/2016

      backup_F_Gates_160233_0010.dist                          4/20/2016

      backup_F_Gates_160244_0011.dist                          3/13/2016



      I would want to only return:

      backup_F_Gates_160212_0008.dist                          5/15/2016

      Is this possible?



        • Re: How to get the Max Date Modified in a folder

          Hey there,

          You could use filetime() function. So in your case


          Load *, filetime() as Time

          From backup_F_Gates_*.dist ;


          You can give it a whirl.



          • Re: How to get the Max Date Modified in a folder
            Massimo Grossi


            Load filetime() as FileTime, FileName() as FileName

            From backup*.dist ;



            NoConcatenate First 1 LOAD * Resident Tmp Order by FileTime desc;


            DROP Table Tmp;


            LET vFile = Peek('FileName');

            TRACE $(vFile);

            • Re: How to get the Max Date Modified in a folder
              Shraddha Gajare

              Try below script:

              It might help.



              set vPath = 'Connectionname';


              for each File in filelist ('ConnectionName\backup_F_Gates_*.dist')



              Load '$(File)' as Name,
                num(FileTime('$(File)')) as FileTime
                autogenerate 1;
              next File



              Load max(Filetime) as ModifiedTime

              Resident fileTable;


              let vMaxTime = num(peek('ModifiedTime',0,'Modified_Time'));


              if len(TableNumber('fileTable')) >= 1 then


              SubField(Name,'\',-1)as File,
              rowno() as Recno

              RESIDENT fileTable
              WHERE FileTime > '$(vMaxTime)'+0.001
              ORDER BY FileTime desc;

              Drop table fileTable;

              Let VMxRows = NoOfRows('FinalTMP');

              if  $(VMxRows) >0 then

              for i=0 to $(VMxRows)-1

              let FileRead = peek('File',$(i),'FinalTMP');

              Load *,
              FileName() as Filename,
              FileTime() as FileTime

              From $(vPath)\$(FileRead);


              End if

              Drop table FinalTMP;