How we get details of every node and its child nodes inside particular nodes

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

How we get details of every node and its child nodes inside particular nodes

Hi we are using Alfresco version 3.4 .

We need details of every file and folder recursively inside a particular node folder using alfreco script.

We try with "childrenByXPath ()", "savedsearch()" and also with "luceneSearch()" in alfresco 3.4 script

but did not get correct result.

 

one more thing when we try with "cmis:document" query we get wrong output.

please suggest on the same

1 Reply
Highlighted
Senior Member II

Re: How we get details of every node and its child nodes inside particular nodes

If cmis or searchQueries won't help, you could recursively scan your folder/file structure. But this is time and memory consuming.

Just store the script in Data Dictionary/scripts and execute it on the directory you want to scan through (with alfresco explorer) and change the line in with the push to fileList according to your needs.

I would not recommend this, but you said your other efforts were in vain.

//This script iterates the current folder and subfolders
//and creates a simple directory list with full pathnames.
var fileList=[];

if(document.isContainer) {
     visit(document);

     logfile = userhome.createFile("fileList " + document.name + " " + document.parent.children.length + ".txt");
     logfile.content=fileList.join("\n");
     logfile.properties.encoding = "UTF-8";
     logfile.properties.mimetype = "text/plain";
     logfile.properties.title = "fileList";
     logfile.properties.description = "list of files in "+document.name;
     logfile.save();
}



function visit(node) {
     for each (var n in node.children) {
          if (n.isDocument) {
               //here push all infos for documents to the fileList
               fileList.push(n.displayPath.slice(14) + "/" + n.name + "\t");
          }
     }
     for each (var n in node.children) {
          if(n.isContainer) {
               //here you could push the folder-infos to the fileList
               visit(n);
          }
     }
}

‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍