Need to split the value and pick the same file from folder

Hello Team,

I have some words which i need to split
"B.Com Certificate / NIIT Limited Experience Letter / NIIT Limited Offer Letter / INTER MarkList "
also i have to pick the same file from folder is anyone help me…

Thanks
Rajnish

Hi @Rajnish_Arora,

First of all, you can split your data with split. You can check for files for each directory using for.

fileArray [str][str] = yourValue.Split(“/“c)
Directory.GetFiles(filePath,item.ToString+”*”)(0)

Hi @muhammedyuzuak
Thanks you for the help but its giving error "Path Exists: Index was outside the bounds of the array’'…

Can you update the fields like this.

yourValue.Split(“/”.ToArray,StringSplitOptions.RemoveEmptyEntries)
Directory.GetFiles(filePath,item.TrimStart.TrimEnd+”*")(0)

Regards,
MY

1 Like

Hi @Rajnish_Arora ,

Assuming we have the string data in a string variable like below :

InputStr = "B.Com Certificate / NIIT Limited Experience Letter / NIIT Limited Offer Letter / INTER MarkList "

Maybe we could try with the Below Steps and Check :

  1. Using an Assign Activity, Split the String/Text data based on / assuming that is the delimiter.
fileNamesArray = Split(InputStr,"/").ToArray

Here fileNamesArray is a variable of Type Array of String.

  1. Next, we find the files from the Folder specified which contains this list of words in their file names like below :
fileList = Directory.GetFiles("YourFolderPath").Where(Function(x)fileNamesArray.Any(Function(y)y.Trim.ToLower.Contains(Path.GetFileNameWithoutExtension(x).ToString.ToLower.Trim))).ToArray

Here, fileList is a variable of Type Array of String. It contains list of file paths matching the Input String Data provided.

Let us know if this doesn’t work.

Hi @muhammedyuzuak

Its working fine but we are facing one issue sometime we are getting pdf and jpg files so how we can make it dynamic so it can take any extension. On attached snip its taking jpg file.

image

This way you can update.

Directory.GetFiles(filePath,item.TrimStart.TrimEnd+”*")

Regards,
MY

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