Skip to main content
Announcements
NEW: Seamless Public Data Sharing with Qlik's New Anonymous Access Capability: TELL ME MORE!
cancel
Showing results for 
Search instead for 
Did you mean: 
pavansonu99
Creator
Creator

find directory is empty or not

can someone help me with script to know whether the directory is empty or not

my requirement is lo load only if the directory is empty.

5 Replies
marcus_sommer

You could run a loop with filelist() over your directory and if filesize() or maybe an own counter is 0 then the directory is empty or contained not the searched files. A good description of them could you find within the help by "for each ..." and also here: Loops in the Script.

- Marcus

girirajsinh
Creator III
Creator III

Hi Pavan

Below script works for me. I hope it will work for you as well. Please try.

SET vPathQvd = 'D:\Girirajsinh\temp\*'; 

TempTable:
load
count(distinct FileName()) as FN
From  [$(vPathQvd)] (biff, embedded labels, table is Sheet1$);

Let vCNT=Peek('FN');

if cnt>0
EXIT SCRIPT;
ELSE
// Wrie here your LOAD
ENDIF

vinieme12
Champion III
Champion III

Try below

Let vFileCount = 0;

For Each vFile in FileList('C:\Users\Vini\Downloads\*')

  Let vFileCount = $(vFileCount) + 1;

Next

  

IF  $(vFileCount) = 0 THEN

//Your Script

End IF

Vineeth Pujari
If a post helps to resolve your issue, please accept it as a Solution.
pavansonu99
Creator
Creator
Author

Thank u Vineeth ur code worked for my requirement.

vinieme12
Champion III
Champion III

Glad to help,

If your query is resolved please close the thread by marking response as correct

Qlik Community Tip: Marking Replies as Correct or Helpful

Vineeth Pujari
If a post helps to resolve your issue, please accept it as a Solution.