Set-Item wsman:\localhost\Client\TrustedHosts serverName -Concatenate -Force
I needed to load the most recent file to load datas in a qlikview app.
My problem was that the most recent file was not based on date time of the file but based with the name of the file. Goal is to load data and sort them desc and return only the first record, so i get the most recent file.
Sub DoDir (Root)
// filetype to search for in current directory, assuming files are excel type (.xls) For Each Ext In 'xls'
For Each File In FileList (Root & '\SC4_SCENE_Dictionnaire de données*.' & Ext)
Load '$(File)' as Name
//if you want to sort by file date time uncomment next line and adapt loop
//FileTime('$(File)') as FileTime,
RangeSum(Peek('FileCount'), 1) as FileCount
// search in subdirectories, uncomment if needed (recursive loop) For Each Dir In DirList (Root & '\*')
Call DoDir (Dir)
//Call the fucntion DoDir with the path to the folder to be scanned
Call DoDir ('CHANGE TO YOUR FOLDER PATH TO BE SCANNED');
FIRST 1 LOAD Name AS MostRecentFileName
ORDER BY Name DESC;
LET vFileToLoad = FieldValue('MostRecentFileName', 1);
//load datas to be used in your qlkview app
LOAD * FROM $(vFileToLoad)(your source parameters);