Handling multiple subfolders in a script
Depending upon the setup that you have to deal with, not all of your source data files may be in one folder. For example, a company may keep transaction files in a separate folder for each year and then one subfolder for each month.
This recipe gives an example of how to use DirList
and FileList
to retrieve files matching a particular filespec
.
Getting ready
Load the following script:
Sub GetFiles(vPath) // Get a list of files with Q extensions For each vFile in FileList('$(vPath)\*.Q*') Files: Load '$(vPath)' as Folder, '$(vFile)' as File, FileSize('$(vFile)') As FileSize, FileTime('$(vFile)') As FileTime AutoGenerate(1); Next End Sub Sub GetSubFolders(vPath) For each vDir in DirList('$(vPath)\*') Folders: Load '$(vDir)' As Folder AutoGenerate(1); Call GetFiles('$(vDir)'); // recurse to get sub folders Call GetSubFolders('$(vDir)'); Next End Sub Call GetFiles...