"FOE EACH FILE IN FOLDER" - How to use NOT logic in filter field?

Hi team,

I am using the for each file in folder activity as shown below

I want to make sure that my loop does not include the files which contains the string “Final_CompanyCode_*.xlsx” in the loop.

It looked simple but it is not working.

experts please help:

@Anil_G @ashokkarale @Yoichi

We would assume that Filter Syntax is based on the Fileglobbing Syntax

But is only offered for include pattern

Moving forward from explanation to solution alternates

One of more options is LINQ and Regex

Assign Activity:
arrFilterResult | Datatype: String Array =

(From fi In New DirectoryInfo("YourPath").GetFiles()
Where Regex.IsMAtch(fi.Name,"YOUR_REGEX_PATTERN, RegexOptions.IgnoreCase)
Select fi.FullName).toArray

taken from:

And also:
[HowTo] LINQ (VB.Net) Learning Catalogue - Help / Something Else - UiPath Community Forum

1 Like

It sounds like you’re working on a file processing automation. Here’s a more standardized approach to achieve what you’re describing:

  1. Remove the filter criteria from the For Each File activity to loop through all files.
  2. Add an If condition within the loop to check if the current file name contains “Final_CompanyCode_”.
  • If the condition is true, either ignore the file or log a trace message.
  • If the condition is false, proceed with processing the file.

This way, you ensure that all files are processed except those containing the specified keyword. Does this approach align with what you had in mind?

Else let us know