How to consider files, containing specific words, and use them in the automation flow?

Hi to all,
I have a “trivial problem”,
but with strings and regexes they are very weak.

There is a folder containing several .xlsx files.
Not all .xlsx files have to be considered by the bot,
but only those that contain the words: “Credit_mngt_affidati_”

(the full name is: Credit_mngt_affidati_2021.xlsx, or the current one

The bot has to perform operations on these two files,
and at the end of processing, it must create an output for each processed file, therefore,
in addition to considering only the “Credit_mngt_released_” files
it will also have to take the full name to use in the Output string.
(ex: Output_Credit_mngt_affidati_2021.xlsx
, or Output_Credit_mngt_released_2022.xlsx)

Can someone help me?


Try below expression to fetch those 2 files.

       arrFiles [] = Directory.GetFiles("YourFolderPath","Credit_mngt*.xlsx")

Use For Each loop activity to iterate one by one file and then process it. At the end creating new output report append Output_ to the filename.

I think I don’t understand what you mean.
I made this flow:

Where Source, is String of my Path.
For Each File in Source, arrFiles= Directory.GetFiles(Source,“Credit_mngt*.xlsx”)

but when i launch the job, a receive this in write line:

In my folder, now there are 3 “Credit_mangt_…” files…

iterate through the array of files .In the above scenario,Source should be the array of files


Create Array of string variable and let’s say arrFiles.

Leftside: arrFiles
Right side: Directory.GetFiles(“YourFolderPath”,“Credit_mngt*.xlsx”)

And then use For Each loop activity and pass arrFiles to it.

Sorry, but I still don’t understand.
My “arrFile” is an Array of String.
Do you have a .xaml stream to share?

unfortunately I have not solved this problem yet.
I share my flow. Can you help me understand what’s wrong?

Main.xaml (6,2 KB)

in the source folder there are 2 files, for now.
“Credit_mngt_affidati_2021_Original.xlsx” and

For each file, I need to get the name, because I need it at the end of the stream to edit the “output” file.

Can help me pls?

Hello @AaronMark,

You can do:

For each item in Directory.GetFiles(“Youfolderroute”)

(Inside loop): If item.toString.Contains(“Credit_mngt_”) Then proceed, Else do nothing

One more error message.
In addition to inserting the IF into the loop,
I still need to collect the file name as well.
(with or without extension, this is indifferent).

Hi @AaronMark
You are passing the Source here what you need to pass is arrfiles in the value


Where item.tostring will get you the path for getting name you need to use this expression and assign in variable and then concatenate with the output file name

Hope this Helps


Hi @AaronMark ,

Change the TypeArgument from System.IO.FileInfo to System.String of For Each loop to avoid the casting error.

Main.xaml (7,5 KB)

Sorry for my inability, it’s definitely my limitation, I still can’t figure out how to fix this step.
Can anyone share a Wflow ?
plss… :expressionless:

@AaronMark ,

No worries.
Main.xaml (7.2 KB)

Please check the attached workflow and confirm.


It was an element that I had not considered,
although I wrote it, but, I never had to change the Type Argument and … nothing … I really didn’t think there was a supplementary setting.
Sorry!! …and Thanks!!

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