<?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 Load the latest file of a folder in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/Load-the-latest-file-of-a-folder/m-p/192463#M54113</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Rakesh,&lt;/P&gt;&lt;P&gt;Thanks for your reply.&lt;/P&gt;&lt;P&gt;I had something similar to that but the problem is that I have somethings like 2000 files in that folder, so the loop will take a bit long. I was thinking that may be something like filelist but reading the first entry if the filelist could return a csv file with the filenames sorted already by last modified or file created or something like that. Let's keep the post open and see if we get another idea, if not the way you suggest which is similar than the one I have at least works. cheers.&lt;/P&gt;&lt;P&gt;Question still open...&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sat, 19 Sep 2009 22:23:50 GMT</pubDate>
    <dc:creator />
    <dc:date>2009-09-19T22:23:50Z</dc:date>
    <item>
      <title>Load the latest file of a folder</title>
      <link>https://community.qlik.com/t5/QlikView/Load-the-latest-file-of-a-folder/m-p/192461#M54111</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I have a folder called Folder1, and in the folder files calld a-13-01-2009.txt and so on with different dates. I can read with s FOR all the files, but takes me too long to determine which one is the latest one so I can load it. Any ideas how I can read a sorted folder so the first file I find to load is the latest and I don't have to loop through the whole folder?&lt;/P&gt;&lt;P&gt;Any ideas would be much appreciated.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 19 Sep 2009 05:59:23 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Load-the-latest-file-of-a-folder/m-p/192461#M54111</guid>
      <dc:creator />
      <dc:date>2009-09-19T05:59:23Z</dc:date>
    </item>
    <item>
      <title>Load the latest file of a folder</title>
      <link>https://community.qlik.com/t5/QlikView/Load-the-latest-file-of-a-folder/m-p/192462#M54112</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Would this be fast enough?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;BLOCKQUOTE style="overflow-x: scroll;"&gt;&lt;PRE style="margin: 0px;"&gt;&lt;BR /&gt;for each File in filelist ('C:\myFolder\*.*')&lt;BR /&gt;Folder:&lt;BR /&gt;Load '$(File)' as Name,&lt;BR /&gt; FileTime( '$(File)' ) as FileTime&lt;BR /&gt; autogenerate 1;&lt;BR /&gt;next File&lt;BR /&gt;LatestFile:&lt;BR /&gt;first 1&lt;BR /&gt;Load&lt;BR /&gt; Name,&lt;BR /&gt; FileTime,&lt;BR /&gt; 1 as dummy&lt;BR /&gt;Resident Folder&lt;BR /&gt;Order By FileTime DESC;&lt;BR /&gt;drop table Folder;&lt;BR /&gt;&lt;/PRE&gt;&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;BR /&gt; &lt;P&gt;Then you can peek into Name and store into a variable, then use variable to load the data.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 19 Sep 2009 10:52:33 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Load-the-latest-file-of-a-folder/m-p/192462#M54112</guid>
      <dc:creator>disqr_rm</dc:creator>
      <dc:date>2009-09-19T10:52:33Z</dc:date>
    </item>
    <item>
      <title>Load the latest file of a folder</title>
      <link>https://community.qlik.com/t5/QlikView/Load-the-latest-file-of-a-folder/m-p/192463#M54113</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Rakesh,&lt;/P&gt;&lt;P&gt;Thanks for your reply.&lt;/P&gt;&lt;P&gt;I had something similar to that but the problem is that I have somethings like 2000 files in that folder, so the loop will take a bit long. I was thinking that may be something like filelist but reading the first entry if the filelist could return a csv file with the filenames sorted already by last modified or file created or something like that. Let's keep the post open and see if we get another idea, if not the way you suggest which is similar than the one I have at least works. cheers.&lt;/P&gt;&lt;P&gt;Question still open...&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 19 Sep 2009 22:23:50 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Load-the-latest-file-of-a-folder/m-p/192463#M54113</guid>
      <dc:creator />
      <dc:date>2009-09-19T22:23:50Z</dc:date>
    </item>
    <item>
      <title>Load the latest file of a folder</title>
      <link>https://community.qlik.com/t5/QlikView/Load-the-latest-file-of-a-folder/m-p/192464#M54114</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Fed, I don't have a technical solution, but more a generic one. If you are interested in loading only the latest file, why don't you consider archving the other files to a separate folder. That way, you can avoid unwanted looping.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 19 Sep 2009 22:50:20 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Load-the-latest-file-of-a-folder/m-p/192464#M54114</guid>
      <dc:creator />
      <dc:date>2009-09-19T22:50:20Z</dc:date>
    </item>
    <item>
      <title>Load the latest file of a folder</title>
      <link>https://community.qlik.com/t5/QlikView/Load-the-latest-file-of-a-folder/m-p/192465#M54115</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;had posted recently a sniplet using the Filelist:&lt;/P&gt;&lt;P&gt;http://community.qlik.com/forums/t/20414.aspx&lt;/P&gt;&lt;P&gt;Believe that the above solution opens each file. We use similar script like the above for some hundreds pretty big text-files located on a distant server with rather low connection-speed&lt;/P&gt;&lt;P&gt;Have Fun!&lt;BR /&gt;Peter&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 19 Sep 2009 23:06:34 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Load-the-latest-file-of-a-folder/m-p/192465#M54115</guid>
      <dc:creator>prieper</dc:creator>
      <dc:date>2009-09-19T23:06:34Z</dc:date>
    </item>
    <item>
      <title>Load the latest file of a folder</title>
      <link>https://community.qlik.com/t5/QlikView/Load-the-latest-file-of-a-folder/m-p/192466#M54116</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;oh! I see your problem.&lt;/P&gt;&lt;P&gt;The best solution I can think of is&lt;/P&gt;&lt;P&gt;1. create a bach file (as below) and place it in the directory. Make sure to change extension in the script. I used csv as an example:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;BLOCKQUOTE style="overflow-x: scroll;"&gt;&lt;PRE style="margin: 0px;"&gt;&lt;BR /&gt;@echo off&lt;BR /&gt;rem *** Delete old autogenerated files&lt;BR /&gt;del AllFiles.tmp&lt;BR /&gt;del LatestFile.tmp&lt;BR /&gt;rem *** Write list of all files in AllFiles.tmp forted descending by datetime&lt;BR /&gt;dir /b/o-d *.csv &amp;gt; AllFiles.tmp&lt;BR /&gt;rem *** Transfer first line from AllFiles.tmp to LatestFile.tmp&lt;BR /&gt;for /f "delims=" %%a in (AllFiles.tmp) do (&lt;BR /&gt; echo %%a &amp;gt; LatestFile.tmp&lt;BR /&gt; exit /b&lt;BR /&gt;)&lt;BR /&gt;&lt;/PRE&gt;&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;BR /&gt; &lt;P&gt;2. Then in your QV Script using EXECUTE command, you can execute this batch file and after execution is done you can read LatestFile.tmp. This will have the name of the latest file. Or you can always remove FOR loop in the batch and read first line of AllFiles.tmp in your QV script.&lt;/P&gt;&lt;P&gt;Hope this makes sense.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 19 Sep 2009 23:32:47 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Load-the-latest-file-of-a-folder/m-p/192466#M54116</guid>
      <dc:creator>disqr_rm</dc:creator>
      <dc:date>2009-09-19T23:32:47Z</dc:date>
    </item>
    <item>
      <title>Load the latest file of a folder</title>
      <link>https://community.qlik.com/t5/QlikView/Load-the-latest-file-of-a-folder/m-p/192467#M54117</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Guys,&lt;/P&gt;&lt;P&gt;Thanks for all your comments and the time spent on this subject, I appreciate that.&lt;/P&gt;&lt;P&gt;The idea of the batch file is interesting, although the folder with the text files is read-only, despite the fact I could create a folder locally, schedule a task and keep the name of the latest file, that is an interesting approach and will keep it in mind, but mantaining in extra file is one more step, that would be the draw back.&lt;/P&gt;&lt;P&gt;One clarification is that I will just read the latest text file and will not keep history of what has been read, everytime I run the reload then the latest file will be reloaded, no qvd files will be kept.&lt;/P&gt;&lt;P&gt;At the moment my script is working (similar to what Rakesh mentions) , but in the future I will have thousands of files there and the speed finding the latest file could be an issue.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 20 Sep 2009 00:50:59 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Load-the-latest-file-of-a-folder/m-p/192467#M54117</guid>
      <dc:creator />
      <dc:date>2009-09-20T00:50:59Z</dc:date>
    </item>
    <item>
      <title>Load the latest file of a folder</title>
      <link>https://community.qlik.com/t5/QlikView/Load-the-latest-file-of-a-folder/m-p/192468#M54118</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;add this macro then call it from your script&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Function GetNewestFile(ByVal sPath)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;sNewestFile = Null ' init value&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Set oFSO = CreateObject("Scripting.FileSystemObject")&lt;/P&gt;&lt;P&gt;Set oFolder = oFSO.GetFolder(sPath)&lt;/P&gt;&lt;P&gt;Set oFiles = oFolder.Files&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;' enumerate the files in the folder, finding the newest file&lt;/P&gt;&lt;P&gt;For Each oFile In oFiles&lt;/P&gt;&lt;P&gt;On Error Resume Next&lt;/P&gt;&lt;P&gt;If IsNull(sNewestFile) Then&lt;/P&gt;&lt;P&gt;sNewestFile = oFile.Path&lt;/P&gt;&lt;P&gt;dPrevDate = oFile.DateLastModified&lt;/P&gt;&lt;P&gt;Elseif dPrevDate &amp;lt; oFile.DateLastModified Then&lt;/P&gt;&lt;P&gt;sNewestFile = oFile.Path&lt;/P&gt;&lt;P&gt;End If&lt;/P&gt;&lt;P&gt;On Error Goto 0&lt;/P&gt;&lt;P&gt;Next&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If IsNull(sNewestFile) Then sNewestFile = ""&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;GetNewestFile = sNewestFile&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;End Function&lt;/P&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 21 Sep 2009 11:41:13 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Load-the-latest-file-of-a-folder/m-p/192468#M54118</guid>
      <dc:creator />
      <dc:date>2009-09-21T11:41:13Z</dc:date>
    </item>
    <item>
      <title>Load the latest file of a folder</title>
      <link>https://community.qlik.com/t5/QlikView/Load-the-latest-file-of-a-folder/m-p/192469#M54119</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks everyone for your input, I got some really good ideas.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 23 Sep 2009 17:39:11 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Load-the-latest-file-of-a-folder/m-p/192469#M54119</guid>
      <dc:creator />
      <dc:date>2009-09-23T17:39:11Z</dc:date>
    </item>
  </channel>
</rss>

