2 Replies Latest reply: Jun 17, 2016 7:16 PM by David Trent RSS

    list of filename - no subfolders, current folder only

    David Trent

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

        • Re: list of filename - no subfolders, current folder only
          Stefan Wühl

          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

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

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