can anyone help me in this..
Hi,
You can use lucene search for searching all the content of type cm:folder for that particular site and then just get the length of the result.
var result = lucene.search("-----Your Query----");
var a = result.length;
Thanks,
Yash
You can use the following javascript code and execute it in a recursive way.
var site = companyhome.childByNamePath("Sites/<site-name>/documentLibrary");
var count = site.children.length;
The above code will give you the number of children present in documentLibrary.
You can use the same to get the subfolders.
Regards,
Kintu
I don't know javascript, can you pls give me the code with recursive logic and also give me the URL pattern for this
Hi Yash..!!
I have no idea about lucene search can tell me the alternate way for getting folders and sub folders
Use the following code:
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);
I hope you know where to use it.
Note: replace the 'test' with your site name.
Regards,
Kintu
It is giving wrong count
Can you once check?
It counts 'documentLibrary' folder as well.
And it is for two levels only, you can use it recursively.
Regards,
Kintu
Hi Kintu Barot,
Thanks for your answer.
if we don't know the how many levels in a particular site, how can we write recursive logic..?
Similar question was asked earlier: https://community.alfresco.com/message/846309-re-can-anyone-help-me-with-custom-webscript-for-findin...
Ask for and offer help to other Alfresco Content Services Users and members of the Alfresco team.
Related links:
By using this site, you are agreeing to allow us to collect and use cookies as outlined in Alfresco’s Cookie Statement and Terms of Use (and you have a legitimate interest in Alfresco and our products, authorizing us to contact you in such methods). If you are not ok with these terms, please do not use this website.