Find file in folder without loop for each

Hello everyone, I need help with this case, I have an excel table which contains specific information to be able to find a pdf file in a folder without using a loop, due to the large number of files that the folder hosts

the name of the files has the following structure:
T01_C50601092100040157037000100001010000002288195183772_E401570370_R3101375519_F20210901_Chocolates_.pdf
T01 → It is static
C506 → It is static
010921 → makes redeference to document date 09/01/2021
000401570370 → is the issuer id (identificacion in excel table)
00100001010000002288 → Invoice (N Fact Electronica in excel table)
195183772 → dynamic random number
E401570370 → Again the issuer id (Identificacion in excel table)
R3101375519-> Receiver Id
F20210901-> Document date again

In this case dynamic file name we cannot do without looping
we can check commonly like below

File.Exists("T01_C506*.pdf")

Regards,
Arivu

@Juan_Esteban_Valencia - if you could share a sample excel sheet (after masking/removing sensitive info), we can take a look.

Yes of course.InformeFinalSAP.xlsx (8.8 KB)

and this would be the pdf that corresponds to the first row of the file, it is identified by its invoice number and issuer id T01_C50601092100040157037000100001010000026582114566373_E401570370_R3101375519_F20210901_Chocolates_.pdf (70.6 KB)

Thanks @Juan_Esteban_Valencia

So Each row in excel will result in only one file in the folder or many???

If u need to check whether that file exists in the folder without Loop

dt1.AsEnumerable().Where(Function(row) System.Text.RegularExpressions.Regex.IsMatch(filename,“T01_C506”+CDate(row(“Fecha Radicación”)).ToString(“ddMMyy”)+row(“identificacion”).ToString+row(“N Fact Electronica”).ToString+"\d{9}"+row(“Identificacion”).ToString+RecieverID+“F”+CDate(row(“Fecha Radicación”)).ToString(“yyyyMMdd”))).Count<>0

This condition query can give u if file exists or not

Well please the RecieverID part with required column u need

Let me if this is the type u need

Regards

Nived N :robot:

Happy Automation

It will only result in a pdf file, there may be several files with the same invoice or with the same issuer id, but only one with the corresponding invoice and issuer id

Hi @Juan_Esteban_Valencia

Just to know ur update

Is it the thing that u are looking for ?