Qlik Community

QlikView App Dev

Discussion Board for collaboration related to QlikView App Development.

Announcements
IMPORTANT security patches for GeoAnalytics Server available to download: READ DETAILS
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

list of filename - no subfolders, current folder only

Many posts exist on how to find all files like *.htm in a given directory.  For example: Load list of files in a Folder

I have a directory that has (say) a thousand saved web pages.  I need the list of *.htm in the high-level directory only, not all the subdirectories.  I could pull back everything and throw out the information from the subdirectories, but the time waste in scanning 1,000 subdirectories unnecessarily is extraordinary!

How can I pull back all/desired files from the top-level directory only?!  (In Windows 7 you can use a '-folder' option to prevent subdirectory search but can't seem to find something similar here.)

1 Solution

Accepted Solutions
swuehl
MVP
MVP

Does the wildcard in the filename really leads to QlikView scanning all subfolders?

Not sure about that.

But using a FOR EACH vFile IN FILELIST(*.htm) ...NEXT

should only scan the working directory.

See

For each..next ‒ QlikView

View solution in original post

2 Replies
swuehl
MVP
MVP

Does the wildcard in the filename really leads to QlikView scanning all subfolders?

Not sure about that.

But using a FOR EACH vFile IN FILELIST(*.htm) ...NEXT

should only scan the working directory.

See

For each..next ‒ QlikView

Not applicable
Author

Looked again at FOR EACH... NEXT approaches I looked at before posting originally.  My issue was not commenting out the 'for each Dir...' which not surprisingly recursively looped through all subdirectories.  <sigh!>

Thanks swuehl for the response.

sub DoDir (Root)

for each Ext in 'htm'

   for each File in filelist (Root&'\*.' &Ext)

     LOAD

      '$(File)' as Name,

      SubField ('$(File)', chr(92), -1) as NameNoPath,

      FileSize( '$(File)' ) as Size,

      FileTime( '$(File)' ) as FileTime

      autogenerate 1;    

   next File

next Ext

/* for each Dir in dirlist (Root&'\*' )

   call DoDir (Dir)

next Dir */

end sub

call DoDir ('C:\Dir1\Dir2')