Cannot delete the last file in a folder in a loop action
Good Afternoon -
I am having an issue where i have a loop, wherein I do some processing to a series of pdfs. After Im done processing, I move the files to an archive folder, and delete from that current folder. This works, except for the last pdf file in the queue. When the bot encounters the delete task for the last file, I receive an error stating: “Unable to delete the file(s) ‘**file location omitted for post**’ because they are being used by another process. Try after sometime.
I have tried entering a delay, but to no avail. Every other file is deleted successfully.
Any ideas?
Page 1 / 1
@Rob 7023 within the loop after processing try to kill pdf service so that no threads will available…
Im sorry, how do i do that?
Actually, when running in debug, i dont even see the pdf service running at all.
I think the bot itself is somehow keeping it open.
@Rob 7023
Could you post a screenshot of your loop action?
REgards
Hi @Rob 7023 ,
Is this specific to a particular file? If that’s the case, have you tried to delete it manually from that folder? If not, please check once and confirm.
This is not relative to a specific file, it is any time we loop through an entire folder of pdf files.
Here is a screenshot of the loop:
the loop initiation:
I deleted the file deletion
This is not relative to a specific file, it is any time we loop through an entire folder of pdf files.
Test it with a separate BOT after keeping the last file in the Folder and try to delete that. See whether you are facing the same issue there or not.
Else, if it is really bothering you then, you can follow the below workaround.
Use Try-Catch package and put the Delete action in Try and put the Continue in Catch. This will help you if the Delete action failed and the bot will continue the loop.
But you may need to delete the file manually once the BOT execution is over.