How to dynamically loop through the PDF's that are saved on our local drive

HI,

Can anyone suggest a best way of looping through the multiple PDF’s (reading data) from local drive and deleting the PDF after the process id done. I tried "delete’ activity to deleted PDF but, name of the file and path of it should be dynamically generated while deleting also. Please suggest me as good possible way to approach.

Thank you

this might helpe :grinning:

1 Like

hey @srikanth999

You can get only “.pdf” from a particular directory with this :slight_smile:

String[ ] = Directory.GetFiles("D:\sample_pdf\", "*.pdf")

now you can iterate it with for each activity.

For your reference :slight_smile: pdf_Read_from_directory.xaml (7.3 KB)

Regards…!!
Aksh

Hi Akash,

I have been able to read strings of multiple PDFs using a For each loop.
Now, I wish to capture the relevant sub string from each PDF into an excel file. How can I do it?

I can get a relevant string from each PDF using REGEX
“Vendor:” +System.Text.RegularExpressions.Regex.Match(output,".+(?=LTD).*").Value

Question:

How do I capture this information into excel - different row for each PDF?
Please, could you help?

Many thanks in advance.

Hey @pramodrai

Just create a datatable with suitable columns as per your needs. then inside your for each just use add data row and add the data into that datatable and after your loop execution done just dump that datatable into an excel.

Regards…!!
Aksh

hi pramodrai ! hope you are doing well. can you please share the .xaml file with me ?