Looping thorug pdf files

Hello i have a for each loop. That goes through a folder of a bunch of pdf files. Then it does something with it. How can i perfrom it so when it goes thorugh the file and perfrom the action. If the action failes, then it shall move to next file, then so on

Put the action into the Try/Catch block

@langsem,

here are the steps:

  1. Use Directory.GetFIles(Path) to get all the files in the folder…
  2. Use for each loop to loop through all the files
  3. Within for each loop, do all the things you need
  4. To skip if fails, try usinf TRY CATCH activities inside the for each loop

the action its pretty deep into the code structure, would it be able to jump all the way out and start over ? or will it just skip it ?

Do you use orchestrator and the RE Framework? If so, it’s easy

  1. In the Init phase, Use Directory.GetFiles(Filepath) to get all the files in the folder
  2. Upload each file name (with full filepath) to orchestrator
  3. In Get Transaction Data phase, get the full filepath of the next item
  4. In the Process phase, do whatever you need to with the file then move onto the next one

The RE Framework can handle unknown exceptions and retry the transaction item and you can program in business exceptions where applicable.

No sry :confused:

Have you tried these @langsem

Not yet, not sure what to put in the try catch ?

As you need to continue when the pdf fails, so we need to use Try catch

so in the try block, i will use a loop again ?

In the loop itself, use try catch for all the activities so that, if one fails, it will move to another activity.

thats inside the loop. Inside the loop i have several actions. inside those actions there are some if else statements, i want it to start from beginning with a new file when the if statement its wrong

Just use TRY CATCH and put all the IF condition inside it

think it would crash then, The actions its very big and splitted into different workflows.

No problem, try it

did not work, its because its different workflows, actions its performed late and early in the code etc.

  1. Use Assign activity to read all files from folder (where PDF files are), put them in a String Array
  2. Use For Each activity to loop through PDF files
  3. In the For Each activity use Try/Catch Activity. Put the action that you want to do to the PDF file in Try block, and in Catch block put action that you want to be preformed when an exception occurs (when action fails) so for your case, just go to next file

Hm think i need to send the xml to make better understanding. Dont think its capeable of putting everything in a try block since the file its so big