How to find file name which contains specific value

Hi all,

I have a bunch of files in a folder. I want to move the file which contains the values that I want into another folder. For example, I want to move a file which has T001 in its name to another folder. How do I do so?

set new variable arr_files As System.String[]

arr_files = Directory.GetFiles(your_root_folder,"*T001*")

You will get a array of strings with the full addresses of the files that you can process.

1 Like

Hi @Adrian_Star ,

how can I show that the process extracted the correct filename in the box? I want the filename of the file to be displayed.

Also, how will the IF activity look like when I want to say “if the file contains T001”

If you will have one match then:

Write Line (or Message Box): arr_files(0)

Or iterate thru items in For Each activity:

For each file in arr_files: //typeArgument = String
    Write Line (or Message Box): file


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