Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Dynamically load list of files from a folder path

Hi all. I have a folder with a number of files in it. I would like to load the list of files in that folder into a table in QlikView. This list changes frequently, so I'd like to run some function where I pass it the file path and it dynamically generates the list of files in that folder, perhaps with a filter for the extension. Is there a function to do this? Thanks!

3 Replies
MayilVahanan

Hi

     I think its helps

Sub loadfiles(Files)

          For Each file in FileList('$(Files)' & '\*.*');

                    LOAD '$(file)' AS FilePath,

                     if(Len(SubField('$(file)','.',-1)) < 8,SubField('$(file)','.',-1),'No Extension') AS FileExtension,

                     FileSize('$(file)') AS FileSize,FileName('$(file)') As FileName,

                     FileTime('$(file)') AS FileTime AutoGenerate 1;

 

          NEXT file;

          For Each subdir in DirList('$(Files)' & '\*');

           CALL subFunction('$(subdir)')

          NEXT subdir;

End Sub

SUB subFunction(Subdir)

          For Each sub in DirList('$(Subdir)')

           CALL loadfiles('$(sub)')

          NEXT sub;

End Sub

Call loadfiles('E:\Qlikview -11')

Thanks & Regards, Mayil Vahanan R
Please close the thread by marking correct answer & give likes if you like the post.
Not applicable
Author

Hey! Very cool! Thanks a lot for that code. One thing though, it seems to work perfectly, except the FileName field comes up empty. Does it do the same for you? I'm running QV11 SR1.

MayilVahanan

hi

Try like this for FileName:

SubField('$(file)','\',SubStringCount('$(file)','\')+1) As FileName

Its give the result

Thanks & Regards, Mayil Vahanan R
Please close the thread by marking correct answer & give likes if you like the post.