I'm trying to find a file which may be in a subfolder, but it could also be inside a subfolder of a subfolder. I've followed this answer's approach, but still...
When I place the file inside the 'second subfolder, the script is not finding it.
function updateClientWb() {
var clientId = 'AA001'
var parent_folderID = 'folderidsafafdasadasda2D-U';
var parent_folder = DriveApp.getFolderById(parent_folderID);
var subFolders = parent_folder.getFolders();
var searchForClientId = "title contains '" + clientId + "'";
var clientSeoProjectWb = [];
while (subFolders.hasNext()) {
var thisSubFolder = subFolders.next();//THIS IS PROBABLY WHERE THE FLAW IS
var clientFiles = thisSubFolder.searchFiles(searchForClientId);
while (clientFiles.hasNext()) {
var files = clientFiles.next();
if (files.getName().indexOf('File Name Part') > -1) {
clientSeoProjectWb.push(files.getId());
}
}
}
return;
}
Appreciate your help