AnsweredAssumed Answered

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

Question asked by raju.gonda on Jul 29, 2019

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);

Outcomes