How to compare invoice number using uipath

Hi Team,
I have one excel with Invoice number (format is .pdf) i am attaching screenshot for your reference below.

I have folder and inside the folder I have invoice number (format .pdf) i am attaching screenshot for your reference below.

My task is how to compare inside the folder invoice number and Excel invoice number.
What ever the invoice number is there in excel same invoice number should be there inside the folder.
How to compare excel invoice number and folder invoice number.
If any invoice number is missing in folder we should send email and stop the process.

Please help me

Hi @Baby123

You can take an array fileNames & get all file names into it by using:

fileNames = directory.getFiles(“PDF folder path”)

Then you can iternate through every element in this array & get their names without extension (811….) using the function:

Path.GetFileNameWithoutExtension(“individual file path from for each”)

Now you can compare the file name against the excel data & report the missing one.

Hope this helps,
Best Regards.


We can do the comparision one by one or can get all together…

If one by one

  1. For each row in datatable…
  2. Then use directory.Getfiles("folderpath,currentrow("invnumber").ToString + "*").count>0 to check if atleast one file is there with the given invoice number

Second aapproach

  1. Directory.Getfiles("folderpath").Select(function(x) path.getfilenamewithoutextension(x)).ToArray this will give all the found filenames alone in an array say arr1
  2. x("invnumber").ToString).ToArray this will give all the invoice numbers in excel as array say arr2
  3. Now arr2.Except(arr1) will give the values that are not present in aar1 but present in aar2 if any

Hope this helps


Hi @Anil_G

It’s working fine thanks for sharing the logic
Thanks a lot Anil

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.