How to select all files including a certain string

You can use the Directory.GetFiles() method in an assign to return all filenames as an array of string. It allows you to use a searchpattern as well, see the documentation here: Directory.GetFiles Method (System.IO) | Microsoft Learn

In your case you could create a string array variable called MyFiles and in an assign activity put the following: Assign MyFiles = Directory.GetFiles(YourDirectoryToSearch,"*_" + YourDateVariable.ToString("yyyyMM") + "_*.csv")

This would grab all files in the directory that have the underscore followed by the date in yyyyMM format, followed by an underscore, and ending in .csv. If you want to search subdirectories, you should include that as a search option.

Now you can iterate through the array of filenames to move them into the folder of your choosing with the ‘move file’ activity. If you need to attach all the files to an email, that is a bit more difficult but you can do it by creating a Mail object and adding all the files using the Mail.attachments.add method. See details here: Option to attach array (string) in send mail for attachment - #9 by Sachin_Desai

3 Likes