How to fetch specific files from a folder?

Hello All,

I need to fetch specific files from a folder by filtering the name.
I need to fetch txt files named Auth_released_20220303.txt,Auth_released_20220304.txt,Auth_released_20220305.txt from a folder. However there are a lot of txt files as well with other names.

How Can I get all the required files?

Any leads or helps are much appreciated.

Hi @Sirimalla_Karthik_Chandra

Have look on the document

Regards
Gokul

Hi @Sirimalla_Karthik_Chandra

Have a look on the XAML file

SpecificFileinFolder.xaml (7.9 KB)

image

Regards
Gokul

1 Like

Hi @Gokul001 , Thank you so much for the help.

Cool @Sirimalla_Karthik_Chandra

happy automation

Regards
Gokul

Hi @Sirimalla_Karthik_Chandra

Since you said that there are a lot of .txt files, using a For each will work, but might make the bot slow.

Another approach you can take is by using LINQ filters in the following way:

1- Define an array containing the desired Filenames:

image

2- Get list of files in folder:

Directory.GetFiles("YourPathHere")

3- Apply the following LINQ:

var_ListOfFiles.Where(function(x) var_SpecificFileNames.Any(Function(y) x.Contains(y))).ToArray

image

This will return in “var_ResultListOfFiles”, the full path of any item included inside the 1st array, if found.

Check the attached workflow if needed!

Demo_ListOfFiles.xaml (7.3 KB)

Best Regards

Hi @ignasi.peiris , Thanks for replying to the post. My query is already solved by @Gokul001.

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