Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Posting on Qlik Community is temporarily paused for some users. Thank you for patience and we'll update you soon!
cancel
Showing results for 
Search instead for 
Did you mean: 
chriys1337
Creator III
Creator III

count files in folder (in Qlik Sense)

Hi,

I found following script, which is counting files in a folder in QlikView (https://community.qlik.com/t5/QlikView-App-Development/count-files-in-folder/td-p/182186😞

 

// Sub-routine for one (sub-)directory
SUB DoDir (Root)

// Load each file in the directory
// SAP_BPCDataFiles__wk_09_FY2018 - BPC WEEKLY SALES
FOR Each File in filelist (Root&'\SAP_Sales_Files_wk_??_FY???? ')

TRACE $(File);
Concatenate(FileList)
load
'$(File)' as FileName,
FileTime('$(File)') as FileTime,
1 as New
AutoGenerate
1
where
not Exists(FileName,'$(File)');

Concatenate(FileList)
load
'$(File)' as FileName,
FileTime('$(File)') as FileTime,
1 as New
Resident
FileList
where
FileName = '$(File)'
and FileTime < FileTime('$(File)');
NEXT File;
// go one level deeper in the directory-structure
FOR Each Dir in dirlist (Root&'\*' )

call DoDir (Dir)

NEXT Dir

ENDSUB

 

----

It seems I have some error, in my re-written code for Sense? Do you have an idea whats wrong?

Set VariableQvdPath = 'lib://Sales\02_Extraction_qvd\';

SUB DoDir (Root) // how to re-write "Root" in Sense?

// Load each file in the directory

FOR Each File in filelist ('$(VariableQvdPath )SAP_Sales_Files_wk_??_FY????') 

TRACE $(File);

Concatenate(FileList)
load
'$(File)' as FileName,
FileTime('$(File)') as FileTime,
1 as New
AutoGenerate
1
where
not Exists(FileName,'$(File)');

Concatenate(FileList)
load
'$(File)' as FileName,
FileTime('$(File)') as FileTime,
1 as New
Resident
FileList
where
FileName = '$(File)'
and FileTime < FileTime('$(File)');
NEXT File;
// go one level deeper in the directory-structure
FOR Each Dir in dirlist ('$(VariableQvdPath )*') // former (Root&'\*' )

call DoDir (Dir)

NEXT Dir

ENDSUB

0 Replies