Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi I have a question,
I want to count number of file that start with DATA*
There area 3 qvd files in my folder, they area DATA1, DATA2, and DATA3.
If file start with DATA exist i want to give a flag.
I have try using this one
LET vListqvdexists=isnull(QvdCreateTime('QVD\DATA*.qvd'));
But it doesn't work.
Do you have any solution ?
try this
LET vListqvdexists=if(Filesize('..\QVD\DATA*.qvd')>0,1,0);
I don't think that the QVD file functions or FileSize can take a wildcard file name. I suggest this script:
Let vListqvdexists = 0;
For Each vFile in FileList('QVD\DATA*.qvd')
Let vListqvdexists = 1;
Next
Lejours,
Try,
Set vRoot = 'C:\Users\Tamil.Nagaraj\Desktop\Path';
FOR Each File in filelist ('$(vRoot)'&'\*.qvd')
let vBaseName = subfield('$(File)','\',SubStringCount('$(File)','\')+1);
If WildMatch('$(vBaseName)','DATA*') Then
Files:
Load '$(vBaseName)' as Name autogenerate 1;
ENDIF
next File
Let vListqvdexists = NoOfRows('Files');
DROP Table Files;
May be something like this
load count(Name) as Filecnt
load filebasename() as Name
from C:\temp\Data* ;
This is a fast way to get the number of files.
I tested the code with 10000 qvd-files in the path, and got the answer in hundreds of a second.
Set vRoot = 'D:\QV\Tester\Files';
Sub NoOfFiles(myPath, myNoOfFiles)
// Count the number of files, meeting creteria, in a path
Let tNoOfFiles = 0;
For Each File In Filelist ('$(myPath)')
// Count +1 for each file in the path
Let tNoOfFiles = tNoOfFiles + 1;
Next
Let $(myNoOfFiles) = tNoOfFiles; // Declare the variable and set the value
Set tNoOfFiles=; // Undeclare
End Sub
// Save the NoOfFiles in variable "vNoOfFiles"
Call NoOfFiles('$(vRoot)\DATA*.qvd', 'vNoOfFiles')