@Davey – thank you for sharing this. The problem was pending. At least for me ;-)
Now, I tested with a slightly altered version of the code from Vamitul (answer #23 here) – not exporting all InDesign files of a folder to PDF, but a selection of files from a folder – using your while loops instead the one by Vamitul.
I can only say:
it's working well.
Thank you!!
Uwe