Hey @michalhyza12 you can use Directory.getfile method to get the file from the folder.
Directory.GetFiles(folderPath, “*.pdf”)
or else you can use Getfiles from folder activity and filter in with *.pdf extension.
pdfFiles = Directory.GetFiles(folderPath, “*.pdf”)
Group Files by Number
Use a For Each to loop over the files and extract the number part using Regex.
Example Regex for file name: (\d+)
Use Match.Value to get the number.
Build a dictionary:
Dict(of String, List(Of String)) filePairs
For each file:
Add to dictionary :
If filePairs.ContainsKey(number) Then
filePairs(number).Add(filePath)
Else
filePairs(number) = New List(Of String) From {filePath}
End If
For Each Pair → Extract Sender from the One Without Date
Loop over the dictionary:
Identify which of the two files does NOT contain a date in the name (Not Regex.IsMatch(filename, “_\d{2}.\d{2}.\d{4}”))
From that file, extract sender name using whatever method you have (DataTable lookup, keyword matching, or actual PDF text extraction with Read PDF Text).
. Move Files to a Folder Named After the Sender
targetFolder = Path.Combine(rootFolder, senderName)
Use Directory.Exists and Directory.CreateDirectory to ensure the folder exists.
Then use Move File activity to move both files (the pair) to the sender folder.
cheers