It fails if there are any non-images in the source folder. For now I have just noted the limitation in the documentation.
- Try to detect if the file is a valid images after loading
gimp-image-is-valid
gimp-file-load - maybe use both
- calling this with an invalid file causes the error so I can't use it
- Filter by extension - this seems to be the only option but I don't like it because it will be lots of code and people may be able to add support for other file types that wouldn't be on the list.