I am using the script below for incremental loading of files copied out to a shared drive and it works great.
I want to change this code to only load the latest file for another application I am working on. Any suggestions how I can determine which file is the most recent? I did not write this code, I got this from the community some time back.
//Creates current table of excel files in the directory for incremental loading to compare to existing
SUB DoDir (Root)
FOR Each File in FileList(Root&'$(vSourceFile)')
LOAD '$(File)' as File_Name
CALL DoDir (vRoot)
FOR i=0 to NoOfRows('Files')-1
LET vFileName = Peek('File_Name', 0, 'Files');
IF Date(Date#(SubField(vFileName, '_', 4), 'DD-MMM-YYYY')) >= vDateFrom and Date(Date#(SubField(vFileName, '_', 5), 'DD-MMM-YYYY')) <= vDateTo then
Thank you all for suggestions. In the end, I convinced them to just save the latest file so we don’t have to worry about this script. But I was able to successfully create the logic to load the last file.