Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
hi,
did anybody know a way to count the files in a defined folder?
I have a folder in which are a lot of powerpoint files. I'd like to open the newest file from this folder with qlikview.
Many Thanks.
Hernandez
Hello,
Do a loop to search for files. The following is basically the same that the sample in the Reference Manual example and loads the most recent:
Sub DoDir (Root)
For Each Ext In 'qvd' // filetype to search for in current directory
For Each File In FileList (Root & '\*.' & Ext)
Files:
Load '$(File)' as Name,
FileTime('$(File)') as FileTime,
RangeSum(Peek('FileCount'), 1) as FileCount
Autogenerate 1;
Next File
Next Ext
For Each Dir In DirList (Root & '\*') // search in sundirectories
Call DoDir (Dir)
Next Dir
End Sub
Call DoDir ('C:\QlikView\QVD'); // Starting point
MostRecentFileName:
FIRST 1 LOAD Name AS MostRecentFileName
RESIDENT Files
ORDER BY FileTime DESC;
LET vFileToLoad = FieldValue('MostRecentFileName', 1);
DROP TABLE MostRecentFileName;
MostRecentQVD:
LOAD *
FROM $(vFileToLoad) (qvd);
Hope that helps.
Hello,
Do a loop to search for files. The following is basically the same that the sample in the Reference Manual example and loads the most recent:
Sub DoDir (Root)
For Each Ext In 'qvd' // filetype to search for in current directory
For Each File In FileList (Root & '\*.' & Ext)
Files:
Load '$(File)' as Name,
FileTime('$(File)') as FileTime,
RangeSum(Peek('FileCount'), 1) as FileCount
Autogenerate 1;
Next File
Next Ext
For Each Dir In DirList (Root & '\*') // search in sundirectories
Call DoDir (Dir)
Next Dir
End Sub
Call DoDir ('C:\QlikView\QVD'); // Starting point
MostRecentFileName:
FIRST 1 LOAD Name AS MostRecentFileName
RESIDENT Files
ORDER BY FileTime DESC;
LET vFileToLoad = FieldValue('MostRecentFileName', 1);
DROP TABLE MostRecentFileName;
MostRecentQVD:
LOAD *
FROM $(vFileToLoad) (qvd);
Hope that helps.
That works!
Thanks!
Nice - thanks for that reply. Exactly what I needed.
This is awesome! I added the FileSize as well so I can quickly comb through and find the largest QVW or QVDs in specific folders or on specific drives.
Very nice.
Thank you.
Tyler
Dear All,
In my case it is not storing the Name of the File into Name Field
i.e Load '$(File)' as Name
Please Help On this !!!