Moving Files in a For Each Loop using Try Catch Activity

I have a For Each Loop that is converting .PDF’s to .TXT in a given folder. Some files will not be able to be converted causing an exception resulting in the loop to stop. I added a TRY/CATCH activity to move those files to a “ERROR” folder; however, the Move File activity in the Catch portion is returning another exception with the message " The process cannot access the file because it is being used by another process." Is there a way to move these files that are causing errors in order to keep the process running unattended? I attached a file of my process.

Main.xaml (11.5 KB)

It seems to me that you are holding those files in memory whilst you are trying to convert them. The best thing to do would be to separate out your activities so you’re not trying to move them whilst they are still “in use”

Worst case you may need to actively drop them from memory using the Garbage Disposer but I wouldn’t have thought this would be necessary.

RD

Thank you for the reply. I had an idea that that was the issue. How would i separate the activities in away that would still accomplish what i’m trying to do? In my opinion (as a new user), the activities seem to be as separated as they can be.

Make a list or table of the items that fail. Then in a separate set of activities, maybe even a separate workflow, go and move the files/folders by looping through that list.

Whenever I run an alternative process the process doesn’t loop after the catch portion has been ran. Is there a way to keep it looping even after an exception has been thrown?

If the issue is with Adobe Reader being used, Try Kill Process Activity option before you move the file.

Try moving the try/catch inside the for-each-file activity. Your current solution will stop after one conversion fails as it “jumps” to the catch block after an exception is thrown.

There’s the problem. Thank you so much @Andreas

Sorry I was reading on my phone and didn’t see the attachment :frowning:

No worries, your input was greatly appreciated!

Hi, Could you share the worked solution. Thanks for the query.