What am I doing wrong with plugins.file.getFolderContents()?

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:

/Users/bevil/Desktop/hpp/IMG_6380.JPG
/Users/bevil/Desktop/hpp/IMG_6381.JPG
/Users/bevil/Desktop/hpp/IMG_6387.JPG

It should return:
/Users/bevil/Desktop/hpp/IMG_6377.JPG
/Users/bevil/Desktop/hpp/IMG_6380.JPG
/Users/bevil/Desktop/hpp/IMG_6381.JPG
/Users/bevil/Desktop/hpp/IMG_6387.JPG
/Users/bevil/Desktop/hpp/IMG_6376.JPG
/Users/bevil/Desktop/hpp/IMG_6378.JPG
/Users/bevil/Desktop/hpp/more/IMG_6372.JPG
/Users/bevil/Desktop/hpp/more/IMG_6373.JPG
/Users/bevil/Desktop/hpp/more/IMG_6384.JPG
/Users/bevil/Desktop/hpp/more/IMG_6386.JPG
/Users/bevil/Desktop/hpp/more/IMG_6388.JPG
/Users/bevil/Desktop/hpp/more/IMG_6478.JPG

Any clue as to what I am doing wrong?

Thanks for any help anyone can give.

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.

Hi Johan. Thank you for the reply.

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?

Thanks again.

Bevil

yes you have to ask first also for all the directories in that first target folder and call your method recursively

getFolderContents also does have an option to also get only the dirs… (and thet you then use again for the jpg search)

Are you really sure that all those jpgs they are really in that directory? Not hidden no other flags on them?

For example in windows you can have a documents dir that just points to really 2 directories in the file system (its a virtual directory)