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

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
Boulanger
Contributor II
Contributor II

Search for files in multiples folders AND root paths

Hello Qlik folks,

I'd like to improve my code and there is a summary of my goal : 

In the more generic way possible, I'd like to implement in all my apps a way to check files integrity.

My QVDs are in various folders and various paths

Thanks to the community, I've found help from previous posts to create a function that loop on every folders next to the path.

 

The files I'd like to check are similar to : 

  • lib://SERVER1/QVD_Files/MasterData/MD.qvd
  • lib://SERVER1/QVD_Files/inventory.qvd
  • lib://SERVER2/Data/backorders.qvd
  • lib://SERVER3/Sources/forecast.qvd

 

My actual code can only loop on a single root (single server) here it is : 

Sub FindFiles (Root)
  For Each File In FileList(Root&'/*')
  SET vFile = '$(File)';
  QVD_Files:
  First 1
  Load
  '$(File)' as FileName,
  Subfield('$(File)','/',-1) as QVDName,
  FileTime( '$(File)' ) as QVDFileTime,
  floor(FileTime( '$(File)' )) as FileTimeNum,
  FileSize('$(File)') as FileSize,
  QvdNoOfRecords('$(File)') as FileEntries

  AutoGenerate 1 ;
  Next File
End Sub

/// Call FindFiles ('lib://SERVER1/QVD_Files/');

/// stuff, check, drop

What would you do to make this generic and able to loop on several folders from different servers (root) ?

Thanks, a lot, for your kind help 🤗

Labels (2)
1 Reply
rwunderlich
Partner Ambassador/MVP
Partner Ambassador/MVP

I think I would just duplicate the Call statement for each directory of interest. 

-Rob