I am extracting invoice Numbers from a pdf. All works fine when there are 5 or 6 Invoices. But as soon as I place 103 Invoices in the folder the automation picks up the 1st one & randomly picks 10th & next 100th & so on. I want it to pick 1, 2,3,4,5…103 so on can anyone please help
Hi @Raks_K
Try this way:
pdfFiles = Directory.GetFiles("YourPdfDirectory").OrderBy(Function(pdf) pdf).ToArray()
YourPdfDirectory
→ Place your PDF folder path here
pdfFiles
is of DataType Array(System.String)
Use For Each loop to iterate through pdfFiles
and do the required process.
Regards
@Raks_K ,
What logic you are applying for file iteration. There is something off with it.
Thanks,
Ashok
I have used below snip method.
Created a For each file in a folder & lastly it write to excel.
Question : How do I get it to pick Invoice 1 then Invoice 2 then so on in a series format and not jumbled up.
Hi @Raks_K
What is your naming format of all the pdfs??
Or please use the above provided syntax in Assign activity and Run a for each loop and check whether the PDF’s are taken in a order.
Regards
Naming of my Pdf is Invoice_1, Invoice_2,Invoice_3 so on till Invoice_103
@vrdabberu Have used above assign activity but it works if I take Invoice 1 to 9, 10 to 19, 20 to 29, in such combos
If I am including 1 to 10 or 1 to 100 it is picking Invoice 1 then Invoice 10 then Invoice 100, etc.
Is there a sure shot solution to get all 103 at once but pick in Sequence.
Hi @Raks_K
Try this:
Arr_fileNames = Directory.GetFiles("yourdirectorypath")
orderedFileNames = (From fileName In fileNames
Let number = Integer.Parse(System.Text.RegularExpressions.Regex.Match(fileName, "\d+").Value)
Order By number
Select fileName).ToArray()
Run a For Each loop for orderedFileNames
.
Regards
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.