"Filter by Name" For Each Folder in Folder

Hello forum,

Today, I’m just curious, and I’m wondering if there is a way that the “Filter by name” property of this activity could accept multiple strings. The case is that I want to use a ‘For Each’ loop in a folder that has 20 folders inside, but I want to skip just one of the folders (whose name I know). I tried adding an array variable to the property with the names of the folders, but the property only accepts strings.

Please note that I know I could make this work by simply adding an ‘If’ inside the loop that checks for the name of the folder I don’t want to process. However, I’m just curious to know whether I can achieve this using only the properties of the activity itself.

In case it can’t be done, then it would be nice if this activity had these functionalities:

  1. Accepting collections for the ‘Filter by name’ property so we can skip certain folders by their name or adding more of a condition property like some ‘For Each’ activities have.
  2. An option to decide whether the name of the folder(s) we input in the properties is to process or to skip.

Thank you very much for the attention

Regards, The Venezuelan RPA Developer

Hi @Luis_Fernando

You can achieve this using expression

Folder = Directory.GetDirectories("folder_fullpath")

Folder = Folders.Where(Function (x) Not New FileInfo(x).Name.Equals("To delete Name Folder")).ToArray

You also can remove using method StartWith, EndWith, Regex etc


1 Like


Probably filter string is same as searchPattern of Directory.EnumerateFiles or Directory.GetFiles.

So, it doesn’t seem to support multiple conditions.


1 Like

Very useful @rikulsilva
Even though the ‘Filter by name’ property doesn’t accept enumerables, So I won’t be able to enter the folders array into the property.

1 Like

Hi @Luis_Fernando


Using this approach you need to change from for each folder in folder to For Each passing the output as argument

It would will be appropriate if the filter field supports more options

correct, very valid option. Thank you once again.

1 Like

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