How to check if a document exists in a folder based on a part of its name?

Hi,

I would like to check if several documents with one same word, in their names, exist?
Main.xaml (8.8 KB)
And then write how many files, with the same word in their names, exist in an excel.

Hi
–use a assign activity like this
out_filepath = Directory.GetFiles(“yourfolderpath”,“*.yourfileextension”)
wher out_filepath is a variable of type string array
–use a for each loop and pass the above variable as input and change the type argument inthe for each property as string
–inside the loop use a if condition like this
item.ToString.Contains(“the word you want to check with”)
if the above condition passes it will go to THEN part where we have these set of activities
like
assign activity, file_count = file_count + 1
where file_count is a int32 variable defined in the variable panel with default value of 0
so this shows the count of the file name has the common word mentioned in the if condition
outside this for each loop and mention a write line activity and mention as file_count.ToString
which would be the count of the file with that word

hope this would help you
Kindly try this and let know for any queries or clarification
Cheers @Lili1

Cheers @Lili1

2 Likes

Thank you very much it looks good!
But I didn’t try to run it because I have this error message:

1 Like

Kindly remove the double quote before and after the in assign value
That is the right side part of the assign activity
It should be simply starting with Directory…

Cheers @Lili1

1 Like

Thank you so much! it did worked properly :tada:

1 Like

Fantastic
Cheers @Lili1

1 Like

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