Finding a File with variable ending and running

Hi Guys,

If anyone can help with a solution here.

So I have a file path with folders and files inside. I want to search this path for any files (xlsm) within this path, ending in a certain text eg: BF_123456 - and then subsequently open this file.

The issue is that the prefix to this variable may be different so not so simple.

Any advice would be much appreciated.

Thanks!

Steps you need to do @Kyleb91

Just reply back where you got stucked :smiley:

  1. Get all the files inside that folder and store in an array of type string
  2. Use that string array and loop through all the folders and get files inside that folder of type xlsm and store them in another array of type string
  3. Use another for each loop inside and check if the file contains that particular string and then close the loop if the particular file is acquired using break condition

Fine
—while getting the file path array from that folder use this expression
arr_filepath = Directory.GetFiles(“yourfolderpath”,”*.xlsm”)

This will get only the xlsm file from that folder
—now use a FOR EACH activity and pass the vaive variable as input and change the type argument as string in the property panel
—inside the loop use IF condition like this
item.ToString.Contains(“BF_123456”)
If true it will go to THEN part where we can use EXCEL APPLICATION SCOPE and pass the file path as item.ToString

Cheers @Kyleb91

Hey @Palaniyappan and @HareeshMR.

Appreciate the speedy responses! Unfortunately I’m still learning and finding it difficult to follow your instructions. What activity to get all files? and then I’m not sure how to convert to the array table. And the rest… :smiley:

I originally had a path exists activity.

Fine let’s go one by one

[quote=“Palaniyappan, post:3, topic:172171”]
arr_filepath = Directory.GetFiles(“yourfolderpath”,”*.xlsm”)
[/quote
We can use ASSIGN activity where arr_filepath is a variable of type array of string, defined in the variable panel

This will get only the xlsm file from that folder

Then this

[quote=“Palaniyappan, post:3, topic:172171”]
—now use a FOR EACH activity and pass the vaive variable as input and change the type argument as string in the property panel
[/quote]]

Use FOR EACH activity and pass the variable arr_filepath as input

Then

Cheers @Kyleb91

Thanks a lot EDD_Exists.xaml (9.5 KB)

How does the above look?

I’m not so sure that it will find the file and not the folder (same name), and whether the above will correctly read/output the designated Cell.

Thanks in advance

@Kyleb91

Use below code in assign activity to get all files from that specific folder

Directory.EnumerateFiles(“\paddystore\AML$\1_AllEDDRA_Tracking\1. EDDRA\2019",”*.xlsm",SearchOption.AllDirectories)

Thanks man - is that just added to my example .xaml above? Getting some errors when assigning that… also I think the $ in my file path is ineligible - could I use an ‘*’ in place of this?