To use this function add it to the class library file named PluginVCDatastoreService.ts
GitHub Repository: https://github.com/SimonSparksUK/Orchestrator
Filename: PluginVCDatastoreService.ts
Description: The following script gets all files in a datastore
Public Function: GetAllVcFileInfo
publicGetAllVcFileInfo(objVcDatastore:VcDatastore,arrVcFileQuery:VcFileQuery[],strFilePath:string="/",strFileName?:string):VcFileInfo[]{
letobjVcHostDatastoreBrowserSearchSpec:VcHostDatastoreBrowserSearchSpec=newVcHostDatastoreBrowserSearchSpec();
objVcHostDatastoreBrowserSearchSpec.details=this.VcFileQueryFlagsGet();
objVcHostDatastoreBrowserSearchSpec.query=arrVcFileQuery;
objVcHostDatastoreBrowserSearchSpec.searchCaseInsensitive=true;
objVcHostDatastoreBrowserSearchSpec.sortFoldersFirst=true;
if (strFileName!==""){
objVcHostDatastoreBrowserSearchSpec.matchPattern= [strFileName];
}
letobjVcHostDatastoreBrowser:VcHostDatastoreBrowser=objVcDatastore.browser;
letstrDatastorePath:string=`[${objVcDatastore.name}]${strFilePath}`;
letobjVcTask:VcTask=objVcHostDatastoreBrowser.searchDatastoreSubFolders_Task(strDatastorePath,objVcHostDatastoreBrowserSearchSpec);
letarrVcHostDatastoreBrowserSearchResults:VcHostDatastoreBrowserSearchResults[]=this.WaitForVcTaskEnd(objVcTask,2)asVcHostDatastoreBrowserSearchResults[];
letarrVcFileInfoReturn:VcFileInfo[]= [];
arrVcHostDatastoreBrowserSearchResults.forEach((objVcHostDatastoreBrowserSearchResults:VcHostDatastoreBrowserSearchResults):void=>{
letarrVcFileInfo:VcFileInfo[]=objVcHostDatastoreBrowserSearchResults.file;
arrVcFileInfoReturn=arrVcFileInfoReturn.concat(arrVcFileInfo);
});
returnarrVcFileInfoReturn;
}Private Function: VcFileQueryFlagsGet
privateVcFileQueryFlagsGet():VcFileQueryFlags{
letobjVcFileQueryFlags:VcFileQueryFlags=newVcFileQueryFlags();
objVcFileQueryFlags.fileSize=true;
objVcFileQueryFlags.fileOwner=true;
objVcFileQueryFlags.modification=true;
objVcFileQueryFlags.fileType=true;
returnobjVcFileQueryFlags;
}TypeScriptDiscover more from Cloud Build Tools
Subscribe to get the latest posts sent to your email.

This was the only practical implementation of the searchDatastoreSubFolders_Task method that I could find. Thank you for this!!