<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Loop through folder file and get Headers in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/Loop-through-folder-file/m-p/1639633#M732535</link>
    <description>&lt;P&gt;Hi Sunny,&lt;/P&gt;&lt;P&gt;facing one more problem..&lt;/P&gt;&lt;P&gt;Have added one more table, first loop is working fine..&amp;nbsp; (It has loaded 3 tables).&lt;/P&gt;&lt;P&gt;But, It's giving wrong tables count..&lt;/P&gt;&lt;P&gt;LET vTableCount = NoOfTables();&amp;nbsp; &amp;nbsp;-- Here returns 2 tables, but I have 3 tables.&lt;/P&gt;&lt;P&gt;Please suggest.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 24 Oct 2019 17:24:35 GMT</pubDate>
    <dc:creator>paulwalker</dc:creator>
    <dc:date>2019-10-24T17:24:35Z</dc:date>
    <item>
      <title>Loop through folder file</title>
      <link>https://community.qlik.com/t5/QlikView/Loop-through-folder-file/m-p/1638531#M732527</link>
      <description>&lt;P&gt;Hi Community,&lt;/P&gt;&lt;P&gt;Hope you are doing all well!!&lt;/P&gt;&lt;P&gt;I have to loop data folder level, each folder has same structure of data different tables.. and header coming from separate table.&lt;/P&gt;&lt;P&gt;I have 2 folders for Jan and Feb, both has category and product table...&lt;/P&gt;&lt;P&gt;Scenario 1: I have to concatenate both Category tables and both Product tables - have to map Headers&lt;/P&gt;&lt;P&gt;Scenario 2: once done looping - have to create QVD(Category and product) and drop the tables.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I did something - individually working fine for me, but looping not working.&lt;/P&gt;&lt;P&gt;Header:&lt;BR /&gt;CrossTable(Field, FieldName, 2)&lt;BR /&gt;LOAD 'Dummy' as Dummy,&lt;BR /&gt;'@'&amp;amp;RowNo() as Key,&lt;BR /&gt;FieldName&lt;BR /&gt;FROM&lt;BR /&gt;[C:\Users\Lenovo\Desktop\Sample Data\Headers\Category.xlsx]&lt;BR /&gt;(ooxml, embedded labels, table is Sheet1);&lt;/P&gt;&lt;P&gt;MappingHeader:&lt;BR /&gt;Mapping Load Key, FieldName Resident Header;&lt;/P&gt;&lt;P&gt;DROP Table Header;&lt;BR /&gt;//===================================================&lt;BR /&gt;Sub ScanFolder(Root)&lt;/P&gt;&lt;P&gt;For Each File in '.txt'&lt;BR /&gt;For Each FileName in FileList(Root &amp;amp;'\*' &amp;amp; File)&lt;/P&gt;&lt;P&gt;Table:&lt;BR /&gt;LOAD *&lt;BR /&gt;// @1,&lt;BR /&gt;// @2&lt;BR /&gt;FROM&lt;BR /&gt;$(FileName)&lt;BR /&gt;//[C:\Users\Lenovo\Desktop\Sample Data\Files\Jan\Category.txt]&lt;BR /&gt;(txt, codepage is 1252, no labels, delimiter is '\t', msq);&lt;/P&gt;&lt;P&gt;RENAME FIELDS USING MappingHeader;&lt;/P&gt;&lt;P&gt;Next FileName;&lt;BR /&gt;Next File;&lt;/P&gt;&lt;P&gt;For Each SubDirectory in DirList(Root &amp;amp;'\*')&lt;BR /&gt;CALL ScanFolder(SubDirectory)&lt;BR /&gt;NEXT SubDirectory&lt;/P&gt;&lt;P&gt;END SUB&lt;/P&gt;&lt;P&gt;Call ScanFolder('Path');&lt;/P&gt;&lt;P&gt;can you please&amp;nbsp; help!!!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 25 Nov 2020 16:16:04 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Loop-through-folder-file/m-p/1638531#M732527</guid>
      <dc:creator>paulwalker</dc:creator>
      <dc:date>2020-11-25T16:16:04Z</dc:date>
    </item>
    <item>
      <title>Re: Loop through folder file and get Headers</title>
      <link>https://community.qlik.com/t5/QlikView/Loop-through-folder-file/m-p/1638552#M732528</link>
      <description>&lt;P&gt;How about this?&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;Header:
CrossTable(Field, FieldName, 2)
LOAD 'Dummy' as Dummy,
	 FileBaseName()&amp;amp;'.@'&amp;amp;RowNo() as Key,
	 FieldName
FROM [Headers\*.xlsx]
(ooxml, embedded labels, table is Sheet1);

MappingHeader:
Mapping
LOAD Key,
	 FieldName
Resident Header;

DROP Table Header;
//===================================================
Sub ScanFolder(Root)

FOR Each File in '.txt'
	
	FOR Each FileName in FileList(Root &amp;amp;'\C*' &amp;amp; File)
	
		tmpCategory:
		LOAD *
		FROM $(FileName)
		(txt, codepage is 1252, no labels, delimiter is '\t', msq);
		
	NEXT FileName;
	
NEXT File;

FOR Each File in '.txt'
	
	FOR Each FileName in FileList(Root &amp;amp;'\P*' &amp;amp; File)
	
		tmpProduct:
		LOAD *
		FROM $(FileName)
		(txt, codepage is 1252, no labels, delimiter is '\t', msq);

	NEXT FileName;
	
NEXT File;

FOR Each SubDirectory in DirList(Root &amp;amp;'\*')
	
	CALL ScanFolder(SubDirectory)

NEXT SubDirectory

END SUB

Call ScanFolder('Files');

QUALIFY *;
			
Category:
NoConcatenate
LOAD *
Resident tmpCategory;

Product:
NoConcatenate
LOAD *
Resident tmpProduct;

DROP Tables tmpCategory, tmpProduct;
UNQUALIFY *;

RENAME FIELDS USING MappingHeader;&lt;/LI-CODE&gt;</description>
      <pubDate>Tue, 22 Oct 2019 19:31:52 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Loop-through-folder-file/m-p/1638552#M732528</guid>
      <dc:creator>sunny_talwar</dc:creator>
      <dc:date>2019-10-22T19:31:52Z</dc:date>
    </item>
    <item>
      <title>Re: Loop through folder file and get Headers</title>
      <link>https://community.qlik.com/t5/QlikView/Loop-through-folder-file/m-p/1638661#M732529</link>
      <description>&lt;P&gt;Thanks for Reply Sunny&lt;/P&gt;&lt;P&gt;Exactly this is what I need,&lt;/P&gt;&lt;P&gt;but problem is - actually my real data more than 20 tables in the folders, is there any way to do looping for the tables ??&lt;/P&gt;&lt;P&gt;is there any possibility ??&lt;/P&gt;&lt;P&gt;-Thanks&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 23 Oct 2019 03:46:24 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Loop-through-folder-file/m-p/1638661#M732529</guid>
      <dc:creator>paulwalker</dc:creator>
      <dc:date>2019-10-23T03:46:24Z</dc:date>
    </item>
    <item>
      <title>Re: Loop through folder file and get Headers</title>
      <link>https://community.qlik.com/t5/QlikView/Loop-through-folder-file/m-p/1638891#M732531</link>
      <description>&lt;P&gt;Try this&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;Header:
CrossTable(Field, FieldName, 2)
LOAD 'Dummy' as Dummy,
	 FileBaseName()&amp;amp;'.@'&amp;amp;RowNo() as Key,
	 FieldName
FROM [Headers\*.xlsx]
(ooxml, embedded labels, table is Sheet1);

MappingHeader:
Mapping
LOAD Key,
	 FieldName
Resident Header;

DROP Table Header;
//===================================================
Sub ScanFolder(Root)

FOR Each File in '.txt'
	
	FOR Each FileName in FileList(Root &amp;amp;'\*' &amp;amp; File)
		
		TRACE $(FileName);
		LET vTableName = 'tmp' &amp;amp; SubField(SubField('$(FileName)', '\', -1), '.', 1);
		TRACE $(vTableName);
	
		$(vTableName):
		LOAD *
		FROM $(FileName)
		(txt, codepage is 1252, no labels, delimiter is '\t', msq);
		
	NEXT FileName;
	
NEXT File;

FOR Each SubDirectory in DirList(Root &amp;amp;'\*')
	
	CALL ScanFolder(SubDirectory)

NEXT SubDirectory

END SUB

Call ScanFolder('Files');

QUALIFY *;

LET vTableCount = NoOfTables();

FOR i = 0 to $(vTableCount)-1

	LET vTableName = TableName(0);
	LET vTableNameNew = Mid(TableName(0), 4);
	
	$(vTableNameNew):
	NoConcatenate
	LOAD *
	Resident $(vTableName);
	
	DROP Table $(vTableName);
	
NEXT

UNQUALIFY *;

RENAME FIELDS USING MappingHeader;&lt;/LI-CODE&gt;</description>
      <pubDate>Wed, 23 Oct 2019 11:02:39 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Loop-through-folder-file/m-p/1638891#M732531</guid>
      <dc:creator>sunny_talwar</dc:creator>
      <dc:date>2019-10-23T11:02:39Z</dc:date>
    </item>
    <item>
      <title>Re: Loop through folder file and get Headers</title>
      <link>https://community.qlik.com/t5/QlikView/Loop-through-folder-file/m-p/1639248#M732532</link>
      <description>&lt;P&gt;Excellent Sunny! Thank You:)&lt;/P&gt;&lt;P&gt;Very Helpful to me!&lt;/P&gt;&lt;P&gt;If we have same field in both the tables, headers are not associating properly... thus have stored in QVD and Dropped the table.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Please see the below code highlighted in red..!&amp;nbsp;&lt;/P&gt;&lt;P&gt;Header:&lt;BR /&gt;CrossTable(Field, FieldName, 2)&lt;BR /&gt;LOAD 'Dummy' as Dummy,&lt;BR /&gt;FileBaseName()&amp;amp;'.@'&amp;amp;RowNo() as Key,&lt;BR /&gt;FieldName&lt;BR /&gt;FROM [Headers\*.csv]&lt;BR /&gt;(ooxml, embedded labels, table is Sheet1);&lt;/P&gt;&lt;P&gt;MappingHeader:&lt;BR /&gt;Mapping&lt;BR /&gt;LOAD Key,&lt;BR /&gt;FieldName&lt;BR /&gt;Resident Header;&lt;/P&gt;&lt;P&gt;DROP Table Header;&lt;BR /&gt;//===================================================&lt;BR /&gt;Sub ScanFolder(Root)&lt;/P&gt;&lt;P&gt;FOR Each File in '.txt'&lt;BR /&gt;&lt;BR /&gt;FOR Each FileName in FileList(Root &amp;amp;'\*' &amp;amp; File)&lt;BR /&gt;&lt;BR /&gt;TRACE $(FileName);&lt;BR /&gt;LET vTableName = 'tmp' &amp;amp; SubField(SubField('$(FileName)', '\', -1), '.', 1);&lt;BR /&gt;TRACE $(vTableName);&lt;BR /&gt;&lt;BR /&gt;$(vTableName):&lt;BR /&gt;LOAD *&lt;BR /&gt;FROM $(FileName)&lt;BR /&gt;(txt, codepage is 1252, no labels, delimiter is '\t', msq);&lt;BR /&gt;&lt;BR /&gt;NEXT FileName;&lt;BR /&gt;&lt;BR /&gt;NEXT File;&lt;/P&gt;&lt;P&gt;FOR Each SubDirectory in DirList(Root &amp;amp;'\*')&lt;BR /&gt;&lt;BR /&gt;CALL ScanFolder(SubDirectory)&lt;/P&gt;&lt;P&gt;NEXT SubDirectory&lt;/P&gt;&lt;P&gt;END SUB&lt;/P&gt;&lt;P&gt;Call ScanFolder('C:\Users\Lenovo\Desktop\Sample Data\Files');&lt;/P&gt;&lt;P&gt;QUALIFY *;&lt;/P&gt;&lt;P&gt;LET vTableCount = NoOfTables();&lt;/P&gt;&lt;P&gt;FOR i = 0 to $(vTableCount)-1&lt;/P&gt;&lt;P&gt;LET vTableName = TableName(0);&lt;BR /&gt;LET vTableNameNew = Mid(TableName(0), 4);&lt;BR /&gt;&lt;BR /&gt;$(vTableNameNew):&lt;BR /&gt;NoConcatenate&lt;BR /&gt;LOAD *&lt;BR /&gt;Resident $(vTableName);&lt;BR /&gt;&lt;BR /&gt;DROP Table $(vTableName);&lt;BR /&gt;&lt;BR /&gt;&lt;FONT color="#FF0000"&gt;&lt;STRONG&gt;RENAME FIELDS USING MappingHeader;&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#FF0000"&gt;&lt;STRONG&gt;STORE $(vTableNameNew) into $(vTableNameNew).QVD(QVD);&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#FF0000"&gt;&lt;STRONG&gt;DROP Table $(vTableNameNew);&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;NEXT&lt;/P&gt;&lt;P&gt;UNQUALIFY *;&lt;/P&gt;&lt;P&gt;EXIT SCRIPT;&lt;/P&gt;</description>
      <pubDate>Thu, 24 Oct 2019 02:47:43 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Loop-through-folder-file/m-p/1639248#M732532</guid>
      <dc:creator>paulwalker</dc:creator>
      <dc:date>2019-10-24T02:47:43Z</dc:date>
    </item>
    <item>
      <title>Re: Loop through folder file and get Headers</title>
      <link>https://community.qlik.com/t5/QlikView/Loop-through-folder-file/m-p/1639420#M732534</link>
      <description>&lt;P&gt;Amazing!! Thanks for sharing.&lt;/P&gt;</description>
      <pubDate>Thu, 24 Oct 2019 10:44:14 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Loop-through-folder-file/m-p/1639420#M732534</guid>
      <dc:creator>sunny_talwar</dc:creator>
      <dc:date>2019-10-24T10:44:14Z</dc:date>
    </item>
    <item>
      <title>Re: Loop through folder file and get Headers</title>
      <link>https://community.qlik.com/t5/QlikView/Loop-through-folder-file/m-p/1639633#M732535</link>
      <description>&lt;P&gt;Hi Sunny,&lt;/P&gt;&lt;P&gt;facing one more problem..&lt;/P&gt;&lt;P&gt;Have added one more table, first loop is working fine..&amp;nbsp; (It has loaded 3 tables).&lt;/P&gt;&lt;P&gt;But, It's giving wrong tables count..&lt;/P&gt;&lt;P&gt;LET vTableCount = NoOfTables();&amp;nbsp; &amp;nbsp;-- Here returns 2 tables, but I have 3 tables.&lt;/P&gt;&lt;P&gt;Please suggest.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 24 Oct 2019 17:24:35 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Loop-through-folder-file/m-p/1639633#M732535</guid>
      <dc:creator>paulwalker</dc:creator>
      <dc:date>2019-10-24T17:24:35Z</dc:date>
    </item>
    <item>
      <title>Re: Loop through folder file and get Headers</title>
      <link>https://community.qlik.com/t5/QlikView/Loop-through-folder-file/m-p/1639656#M732536</link>
      <description>&lt;P&gt;Since the NoOfTable() is outside the loop, we should not see the value of vTableCount change, but the problem might be with&amp;nbsp;&lt;SPAN&gt;LET vTableName = TableName(0); because by dropping the table you are changing the Tables and there indexes in your load script.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;If you don't mind me asking, what issue did you run into when you did not store/drop the table?&lt;/P&gt;</description>
      <pubDate>Thu, 24 Oct 2019 18:32:51 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Loop-through-folder-file/m-p/1639656#M732536</guid>
      <dc:creator>sunny_talwar</dc:creator>
      <dc:date>2019-10-24T18:32:51Z</dc:date>
    </item>
    <item>
      <title>Re: Loop through folder file and get Headers</title>
      <link>https://community.qlik.com/t5/QlikView/Loop-through-folder-file/m-p/1639722#M732537</link>
      <description>&lt;P&gt;below example, both tables has &lt;STRONG&gt;CategoryID&lt;/STRONG&gt; field, Product table CategoryID storing &lt;STRONG&gt;Product.@1....&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;If we have duplicate fields also storing &lt;STRONG&gt;Product.@1, Product.@2..so on&lt;/STRONG&gt; - Unique fields are storing fine..&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Capture.PNG" style="width: 400px;"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/22323iF7E7B0E925B09A57/image-size/large?v=v2&amp;amp;px=999" role="button" title="Capture.PNG" alt="Capture.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;DIV class="mceNonEditable lia-copypaste-placeholder"&gt;&amp;nbsp;&lt;/DIV&gt;&lt;P&gt;and I have added 3 tables now, but 3rd tables not storing..&lt;/P&gt;&lt;P&gt;I did check with without Store/Drop as well..&lt;/P&gt;&lt;P&gt;NoOfTables() - The number of tables that were loaded, right ??&amp;nbsp;&lt;BR /&gt;TableName('Index') - the name of the table based on its number in the list of tables&lt;/P&gt;&lt;P&gt;my understand, my table count returns wrong ??&lt;/P&gt;&lt;P&gt;PFA,&lt;/P&gt;&lt;DIV class="mceNonEditable lia-copypaste-placeholder"&gt;&amp;nbsp;&lt;/DIV&gt;</description>
      <pubDate>Fri, 25 Oct 2019 03:12:25 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Loop-through-folder-file/m-p/1639722#M732537</guid>
      <dc:creator>paulwalker</dc:creator>
      <dc:date>2019-10-25T03:12:25Z</dc:date>
    </item>
    <item>
      <title>Re: Loop through folder file and get Headers</title>
      <link>https://community.qlik.com/t5/QlikView/Loop-through-folder-file/m-p/1639882#M732539</link>
      <description>&lt;P&gt;Yup, I see now what you mean. It seems like an issue which has been asked before as well&amp;nbsp;&lt;A href="https://community.qlik.com/t5/QlikView-App-Development/Rename-fields-using-mapping-table/td-p/775978" target="_blank" rel="noopener"&gt;Rename fields using mapping table&lt;/A&gt;&amp;nbsp;. Anytime the FieldName repeats, the Rename command is not able to handle it&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Capture.PNG" style="width: 205px;"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/22356i349A0EF7F3A2B63C/image-size/large?v=v2&amp;amp;px=999" role="button" title="Capture.PNG" alt="Capture.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;May be&amp;nbsp;&lt;a href="https://community.qlik.com/t5/user/viewprofilepage/user-id/6622"&gt;@hic&lt;/a&gt;&amp;nbsp;can provide ideas.&lt;/P&gt;&lt;P&gt;Best,&lt;BR /&gt;Sunny&lt;/P&gt;</description>
      <pubDate>Fri, 25 Oct 2019 11:39:53 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Loop-through-folder-file/m-p/1639882#M732539</guid>
      <dc:creator>sunny_talwar</dc:creator>
      <dc:date>2019-10-25T11:39:53Z</dc:date>
    </item>
    <item>
      <title>Re: Loop through folder file and get Headers</title>
      <link>https://community.qlik.com/t5/QlikView/Loop-through-folder-file/m-p/1639959#M732540</link>
      <description>&lt;P&gt;Oops.. Sunny another query...&lt;/P&gt;&lt;P&gt;Sorry for trouble you!!&lt;/P&gt;&lt;P&gt;Why it has concatenated both tables &lt;STRONG&gt;Product &lt;/STRONG&gt;and&lt;STRONG&gt; Sales.&lt;/STRONG&gt;. that should be synthetic key??&lt;/P&gt;&lt;P&gt;Both tables 2 fields are common and 3rd field is the different (Sales and Amount)- it should not be concatenate - right ????&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Capture.PNG" style="width: 239px;"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/22368iA8D7192917A4AECB/image-size/large?v=v2&amp;amp;px=999" role="button" title="Capture.PNG" alt="Capture.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="1.PNG" style="width: 353px;"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/22369i00E1AA2AE8F3A91C/image-size/large?v=v2&amp;amp;px=999" role="button" title="1.PNG" alt="1.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 25 Oct 2019 14:45:48 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Loop-through-folder-file/m-p/1639959#M732540</guid>
      <dc:creator>paulwalker</dc:creator>
      <dc:date>2019-10-25T14:45:48Z</dc:date>
    </item>
    <item>
      <title>Re: Loop through folder file and get Headers</title>
      <link>https://community.qlik.com/t5/QlikView/Loop-through-folder-file/m-p/1639961#M732542</link>
      <description>&lt;P&gt;Here you go&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;Header:
CrossTable(Field, FieldName, 2)
LOAD 'Dummy' as Dummy,
	 FileBaseName()&amp;amp;'.@'&amp;amp;RowNo() as Key,
	 FieldName
FROM [Headers\*.csv]
(ooxml, embedded labels, table is Sheet1);

MappingHeader:
Mapping
LOAD Key,
	 FieldName
Resident Header;

DROP Table Header;
//===================================================
Sub ScanFolder(Root)

FOR Each File in '.txt'
	
	FOR Each FileName in FileList(Root &amp;amp;'\*' &amp;amp; File)
		
		TRACE $(FileName);
		LET vTableName = 'tmp' &amp;amp; SubField(SubField('$(FileName)', '\', -1), '.', 1);
		TRACE $(vTableName);
		
		If NoOfRows('$(vTableName)') &amp;gt; 0 then
	
			Concatenate($(vTableName))
			LOAD *
			FROM $(FileName)
			(txt, codepage is 1252, no labels, delimiter is '|', msq, header is 1 lines);
		
		ELSE
			
			$(vTableName):
			NoConcatenate
			LOAD *
			FROM $(FileName)
			(txt, codepage is 1252, no labels, delimiter is '|', msq, header is 1 lines);
			
		ENDIF;
				
	NEXT FileName;
	
NEXT File;

FOR Each SubDirectory in DirList(Root &amp;amp;'\*')
	
	CALL ScanFolder(SubDirectory)

NEXT SubDirectory

END SUB

Call ScanFolder('Files');

QUALIFY *;

LET vTableCount = NoOfTables();
TRACE $(vTableCount);

FOR i = 0 to $(vTableCount)-1

	TRACE $(i);
	LET vTableName = TableName(0);
	LET vTableNameNew = Mid(TableName(0), 4);
	
	$(vTableNameNew):
	NoConcatenate
	LOAD *
	Resident $(vTableName);
	
	DROP Table $(vTableName);

NEXT

UNQUALIFY *;

RENAME FIELDS USING MappingHeader;

//STORE $(vTableNameNew) into $(vTableNameNew).QVD(QVD);

EXIT SCRIPT;&lt;/LI-CODE&gt;</description>
      <pubDate>Fri, 25 Oct 2019 14:45:45 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Loop-through-folder-file/m-p/1639961#M732542</guid>
      <dc:creator>sunny_talwar</dc:creator>
      <dc:date>2019-10-25T14:45:45Z</dc:date>
    </item>
    <item>
      <title>Re: Loop through folder file and get Headers</title>
      <link>https://community.qlik.com/t5/QlikView/Loop-through-folder-file/m-p/1639969#M732543</link>
      <description>&lt;P&gt;This is working Perfect!!&amp;nbsp; and Rename field name issue also solved.&lt;/P&gt;&lt;P&gt;Thank You so much Sunny &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 25 Oct 2019 15:02:17 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Loop-through-folder-file/m-p/1639969#M732543</guid>
      <dc:creator>paulwalker</dc:creator>
      <dc:date>2019-10-25T15:02:17Z</dc:date>
    </item>
    <item>
      <title>Re: Loop through folder file and get Headers</title>
      <link>https://community.qlik.com/t5/QlikView/Loop-through-folder-file/m-p/1639984#M732544</link>
      <description>&lt;P&gt;How did you solve the rename field issue?&lt;/P&gt;</description>
      <pubDate>Fri, 25 Oct 2019 15:39:16 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Loop-through-folder-file/m-p/1639984#M732544</guid>
      <dc:creator>sunny_talwar</dc:creator>
      <dc:date>2019-10-25T15:39:16Z</dc:date>
    </item>
    <item>
      <title>Re: Loop through folder file and get Headers</title>
      <link>https://community.qlik.com/t5/QlikView/Loop-through-folder-file/m-p/1640242#M732546</link>
      <description>&lt;P&gt;"Rename Fields" cannot merge two loaded fields that are named differently.&lt;/P&gt;
&lt;P&gt;To merge fields, you need to use an "Alias" statement before the Load. E.g.&lt;/P&gt;
&lt;P&gt;Alias "x" as NewField;&lt;BR /&gt;Load x, ... From ... Table1;&lt;BR /&gt;Alias "y" as NewField;&lt;BR /&gt;Load y, ... From ... Table2;&lt;/P&gt;
&lt;P&gt;The problem is to get the information from a mapping table into an Alias statement, but it can be done using variables and dollar expansions.&lt;/P&gt;</description>
      <pubDate>Mon, 28 Oct 2019 09:02:19 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Loop-through-folder-file/m-p/1640242#M732546</guid>
      <dc:creator>hic</dc:creator>
      <dc:date>2019-10-28T09:02:19Z</dc:date>
    </item>
    <item>
      <title>Re: Loop through folder file and get Headers</title>
      <link>https://community.qlik.com/t5/QlikView/Loop-through-folder-file/m-p/1640317#M732547</link>
      <description>&lt;P&gt;Thanks Henric!! I have never used Alias before, but will play around with the idea to see if I can figure this out.&lt;/P&gt;&lt;P&gt;Thank you,&lt;BR /&gt;Sunny&lt;/P&gt;</description>
      <pubDate>Mon, 28 Oct 2019 11:36:35 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Loop-through-folder-file/m-p/1640317#M732547</guid>
      <dc:creator>sunny_talwar</dc:creator>
      <dc:date>2019-10-28T11:36:35Z</dc:date>
    </item>
  </channel>
</rss>

