I have written the following javascirpt code snipped in Alfresco CMS to find and print names of files whose mimetype is "image/png" into a book.txt file. This code creates the book.txt file successfully, but it is blank; it does not write any name of files whose mimeType is "image/png", though there are more than 100 png images files with mimetype 'image/png':
var logFile = space.childByNamePath("book.txt");
if (logFile == null)
{
logFile = space.createFile("book.txt");
}
if (logFile != null)
{
var docs = search.luceneSearch("content.mimetype:'image/png'");
var log = "";
for (var i=0; i<docs.length; i++)
{
log += "Name: " + docs[i].name + "\tPath: " + docs[i].displayPath + "\r\n";
}
logFile.content += log;
}
Any suggestion what is the wrong with this code. I have put this code inside "company home>Data Dictionary>script" and I am running this script from "company home>Sites" which is root of all contents. Hence it is the root of all folders which contains images files. Please advise.
please try using this may help you
search.luceneSearch('+PATH:"/app:company_home//*" +@\\{http\\://www.alfresco.org/model/content/1.0\\}content.mimetype:text/plain');
content.mimetype:text/plain
please specify your mimetype here
you can find more information from documentation