I want to iterate through the tree structure of the folder in Google Drive using google apps script. The code below is listing some of the folders but not all. Can you advic
This should do the trick:
function start() {
folder = DriveApp.getFolderById("0B_5HSTQXtXmsOHBzcnc2dTlkRFU")
listFolders(folder)
}
function listFolders(folder) {
//starting point, we come here from start() or from the bottom of this function
//check the name
var name = folder.getName();
if (name.match("TITL")) {
folder.addEditor("somePerson@gmail.com");
}
//now see if this folder has subfolders
var subfolders = folder.getFolders();
//if it has, we call this function again
while (subfolders.hasNext()) {
listFolders(subfolders.next());
}
}