I am trying to get a listing of all of the image files in a folder (in multiple directories), and add them to blobs in Servoy.
I am failing at the first hurdle though. my getFolderContents will not give consistent results (I am testing this in Developer, not Client)
My code is:
var theFolder = plugins.file.showDirectorySelectDialog();
}
if (theFolder)
{
var files = plugins.file.getFolderContents(theFolder, ['jpg','JPG','jpeg']);
for (var i=0; i<files.length; i++)
application.output(files[i].getAbsolutePath());
}
In a folder containing 6 jpgs, and a folder containing another 6 jpgs, the output is:
getFolderContents is not recursive, it gives you all the files (or direct folders) that ends with the the filter names that you give so if a folder thats in the “theFolder” would end on “jpg” then it would also be reported.
but why it does not return the other 3 jpgs (like 77,76 and 78) i don’t know that should be returned just fine. Is there anything different on those files in that dir compared to others?
By the way, you shouldn’t need to do both “jpg” and “JPG” we are using a case insensitive lookup already.
I didn’t know about the case insensitivity (I think I was following someone else’s example on that).
There is nothing different about these particular jpgs, and there is no error in Servoy (which would tell me that it had failed to do some of them). It is odd
If getFolderContents() will not work recursively, is there some way that I can interrogate the file system that would work recursively?