Skip to main content
Announcements
Qlik Introduces a New Era of Visualization! READ ALL ABOUT IT
cancel
Showing results for 
Search instead for 
Did you mean: 
thomas_evans
Partner - Contributor III
Partner - Contributor III

List folders within a directory

Hi All,

Haven't managed to find anything online which seems to work.

I have a folder lets say D:\Backup. Within that folder I have a series of folders, one for each day i.e. backup20180101, backup20180102 and so on. I am trying to write a script that will return the subfolder names into a single table. I know how to get this for the files contained within, but in this case I need the folder names.

Can anyone give any hints here, I have tried Directory and DoDir functions in a loop, but couldn't seem to get anything to work..

Thanks!!

5 Replies
andrey_krylov
Specialist
Specialist

Hi Thomas. Maybe this


For each vSubDir in dirlist( 'D:\Backup\*' )

  Table: LOAD '$(vSubDir)' as DirName AutoGenerate 1;

Next SubDirectory

thomas_evans
Partner - Contributor III
Partner - Contributor III
Author

Hi Andrey,

Ran the code, doesn't seem to return any results... ?

andrey_krylov
Specialist
Specialist

Sorry Thomas, my mistake. Confused in the variables...


For each vSubDir in dirlist( 'D:\Backup\*' )

  Table: LOAD '$(vSubDir)' as DirName AutoGenerate 1;

Next vSubDir

Krishn
Contributor II
Contributor II

Hello

This also do not gives any result.

Regards

Krishn

lachlanwcast
Partner - Contributor III
Partner - Contributor III

Hi there,

The script by andrey_krylov works for me - but perhaps may not always work if you have the default file system restriction switched on on the newer versions of Qlik.

Here is something from the Qlik website that may assist - Example 2: Creating a list of files on disk:

https://help.qlik.com/en-US/sense/April2020/Subsystems/Hub/Content/Sense_Hub/Scripting/ScriptControl...

You can adjust this to load a list of folders by adding something like a subfield to the '$(File)'