Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi everyone,
We're migrating our Qlik Sense apps to our new Qlik Cloud tenant and noticed a different behaviour for the FileList() function in a for each loop : it now lists every file located in a subfolder.
For example let's suppose this directory :
\DATA\APP1\FILE1.qvd
\DATA\APP1\FILE2.qvd
\DATA\APP1\BACKUP\FILE1.qvd
\DATA\APP1\BACKUP\FILE2.qvd
In Qlik Sense, using the command FOR EACH File IN FILELIST('lib://DATA\APP1\*.qvd') only the first 2 files were looped through.
In Qlik Cloud, the equivalent command FOR EACH File IN FILELIST('lib://DataSpace:DATA\APP1\*.qvd') loops through the first 2 but also the other 2 files located in the BACKUP subfolder.
Is this the intended behaviour ? I couldn't find any mention of it on Qlik Help.
We've found a solution that would be to add a check on the file name containing "/" => if it does it means we're on a subfolder. But does anyone know if there's a simpler solution ? Maybe a simple parameter on the FileList function needs to be added ?
Thanks for your help !
Hi @fabio_c
In my opition, the easiest way is to count how many backslashes are in the FileName string
for each File in filelist ('lib://Exemplo:DataFiles/*.*')
LET FileSlash = Len(File) - Len(Replace(File, '/', ''));
if FileSlash <= 3 then
Dados:
LOAD
'$(File)' as Name,
Round(FileSize( '$(File)' )/1024/1024,2) as SizeMB,
FileTime( '$(File)' ) as FileTime
autogenerate 1;
end if;
next File
Bye!