can anyone modify the code and recursive logic so that i get all the folders and subfolders count in a site

cancel
Showing results for 
Search instead for 
Did you mean: 
raju_gonda
Member II

can anyone modify the code and recursive logic so that i get all the folders and subfolders count in a site

var site = companyhome.childByNamePath("Sites/test/documentLibrary");
var children = site.children;
var numberOfChildren = site.children.length;
var count = 0;

for (var index = 0; index < numberOfChildren; index++) {
      if(children[index].isContainer){
          c = children[index].children.length;
          count = count + c + 1;
      } else {
          //uncomment following line if you want to count the document as well
          //count = count +1;
      }
}
logger.log(count);