Qlik Community

QlikView Scripting

Discussion Board for collaboration on QlikView Scripting.

Announcements
QlikView Fans! We’d love to hear from you.
Share your QlikView feedback with the product team… Click here to participate in our 5-minute survey.
Rules, plus terms and conditions, can be found here.
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.)

Tags (1)
1 Solution

Accepted Solutions
MVP
MVP

Re: list of filename - no subfolders, current folder only

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

2 Replies
MVP
MVP

Re: list of filename - no subfolders, current folder only

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

Re: list of filename - no subfolders, current folder only

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')

Community Browser