Discussion board where members can get started with Qlik Sense.
Hello! So I want to get all the files from a directory in Qlik Sense Desktop.
Found a nice post on the forum
Set vConcatenate = ;
'' AS SourceFile
for each FileExtension in 'qvw'
for each FoundFile in filelist(Root & '\*.' & FileExtension)
LOAD '$(FoundFile)' as SourceFile
Set vConcatenate = Concatenate;
for each SubDirectory in dirlist( Root & '\*' )
Call ScanFolder('C:\Users\Public\Pictures\Sample Pictures\') ;
But It's not working. The FoundFile variable is always null. I've tried with different methods and I get Null every time.
There is another example on this page Attribute ‒ Qlik Sense
But those are not working either.
What is wrong?
Go to Solution.
I just ran this code against one of my Data Connections and added a .csv extenstion and it ran and returned all of the files correctly.
I would suggest that you try this code. Create a data connection to your folder and then change the lib statement to point to the name of the new data connection.
That should work
If you are in Qlik Sense I think the issue is that you are looking for qvw extensions which are QlikView. You want to look for qvf extensions for Qlik Sense.
The Extension is not the problem. I wanted to look for pictures originally then I changed the extension. The extension variable is working. The problem is probably with the file path and how it concatenates the Root, wildcard and extension.
Try putting some trace statements in your script and maybe you can see where it is going wrong.
This is getting annoying.
Found another example in the documentation http://help.qlik.com/en-US/sense/3.1/Subsystems/Hub/Content/Scripting/ScriptControlStatements/For%20...
Still Not working.
I might be crazy but I think that the wildcard is not evaluated
try using this approach...
How to use regular expressions
It's a QlikView file, but you could try the same approach in Sense.
I think that something is missing from that example because it just "loads" from some files and 2 inline tables, but the files are not set in the download section.
Yes! It finally Worked with a connection.
Created Images Folder Connection then modified the script and all images were loaded. Thanks!
for each FileExtension in 'jpg'
let vThing = Root & '*.' & FileExtension;
for each File in filelist(vThing)
LOAD '$(File)' as SourceFile
Call ScanFolder('lib://Images/') ;