hacky
(NotHacker)
December 13, 2024, 11:13am
1
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
ppr
(Peter Preuss)
December 13, 2024, 11:22am
2
We would assume that Filter Syntax is based on the Fileglobbing Syntax
But is only offered for include pattern
ppr
(Peter Preuss)
December 13, 2024, 11:31am
3
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:
This CheatSheet introduces the basic use of available functionalities provided by the .Net API in order to deal with the filesystem. With further examples also special cases are presented.
Basic Usage
System.IO.Directory
Directory offers some static methods for basic operations on folder and subfolders
arrFullFilePaths | String() = Directory.GetFiles("C:\_demo\FileSystem\SubfolderA")
Visuals [grafik]
[grafik]
[grafik]
System.IO.DirectoryInfo
The DirectoryInfo class offers instance methods …
And also:
[HowTo] LINQ (VB.Net) Learning Catalogue - Help / Something Else - UiPath Community Forum
1 Like
sharazkm32
(Sharaz K M)
December 13, 2024, 11:53am
4
It sounds like you’re working on a file processing automation. Here’s a more standardized approach to achieve what you’re describing:
Remove the filter criteria from the For Each File
activity to loop through all files.
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