Closed runegan closed 6 years ago
Original comment by Zack Lovatt (Bitbucket: zlovatt, GitHub: zlovatt).
Here's a version w/ filter--
/**
* Recursively scan folder for all files matching filter
*
* @param {Folder|String} folder - Folder or path to get files from
* @param {String|Function} filter - Filter string or function
* @returns {File[]} - Array of found files
*/
function recursiveGetFiles (folder, filter) {
var foundItems = aeq.arrayEx();
var folderObject = aeq.file.getFolder(folder);
if (aeq.isNullOrUndefined(folderObject))
return foundItems;
// Find all folders within folderObject, and recursively append anything it finds to foundItems
aeq.file.getFiles(folderObject).filter(function (item) {
return aeq.isFolder(item);
}).forEach(function (folderItem) {
foundItems = foundItems.concat(recursiveGetFiles(folderItem, filter));
});
var filesInFolder = aeq.file.getFiles(folderObject, filter);
if (!aeq.isNullOrUndefined(filesInFolder))
foundItems = foundItems.concat(filesInFolder);
return foundItems;
}
Original report by Zack Lovatt (Bitbucket: zlovatt, GitHub: zlovatt).
Something like this? Or as a flag to the existing
aeq.file.getFiles()
function