cancel
Showing results for 
Search instead for 
Did you mean: 

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

raju_gonda
Champ in-the-making
Champ in-the-making

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

0 REPLIES 0