With for each, it shouldn’t happen as it executes files one by one unlike parallel for each.
However, you can still try doing below:
- Instead of getting all files from folders/subfolders in a list and traversing through that, get just list of folders.
- Then traverse through each folder one by one, within that have another loop to traverse through files in that folder one by one. Inside this inner loop, have your code for digitizing and classifying…
try this and see if this resolves your issue.
Also, might be worth checking – if everytime bot is failing after same processing number of files, there might be a chance that particular files is damaged thus leading to the error. So to pinpoint this, print name if file being processed and identify bot is failing at which file and then may be just delete that file or move that file from that folder for a moment and see how it goes with rest of the files.
Plus, sometimes, same OCR is unable to digitize all kinds of files so you may use try catch to catch this exception and under catch activity, defining digitize activity with some other OCR to see if changing OCR resolved the issue or not.
Hope any of the these recommendations work for you.