1 Reply Latest reply: Oct 25, 2016 11:50 AM by Todd Ohme RSS

    adjust script to load all quads from folders 2 levels below root directory

    Todd Ohme

      I think this is a simple adjustment to the code below but just having trouble as this is a new area for me.


      I have sales data stored to QVDs by account, by year, by week, a folder structure like this.  I'm simply trying to load * qvd files into a table in script


      Root folder

                 Seller 1


                                        'Weekly POS Y2011 W1.qvd'

                                        'Weekly POS Y2011 W2.qvd'


                                        'Weekly POS Y2012 W1.qvd'


                 Seller 2


                                        'Weekly POS Y2011 W1.qvd'

                                        'Weekly POS Y2011 W2.qvd'


      Here is the script I am working with.  It appears to successfully grab the first Seller qvds, but that is all, so I just need to adjust to loop thru all.  It looks like this code is set up to find all qvds in the root or subfolder, I just need to search for any qvds within folders within folders  within the root.  Thankful for any help here!


      Set vConcatenate = ;

      sub ScanFolder(Root)

                for each FileExtension in 'qvd'

                          for each FoundFile in filelist( Root & '\*.' & FileExtension)

                                    [WEEKLY POS DATA]:


                                    LOAD * //, '$(FoundFile)' as SourceFile

                                    FROM [$(FoundFile)] (qvd); //(txt, codepage is 1252, embedded labels, delimiter is ',', msq, header is 2 lines);

                                    Set vConcatenate = Concatenate;

                          next FoundFile

                next FileExtension

                for each SubDirectory in dirlist( Root & '\*' )

                          call ScanFolder(SubDirectory)

                next SubDirectory

      end sub


      Call ScanFolder('[lib://QVD Files/POS QVD FILES\WEEKLY POS]');