Match file name and move

Hello friends,
@rkelchuri, @Ninett_Panfir, @Rammohan91, @balupad14, @Florent_Salendres, @vvaidya, @Palaniyappan, @ClaytonM, @vvaidya

I need to check if in a folder there are two files with the same name but with two different extensions (.xml and pdf).
How to perform this check?
In case there only one of the two I should move the file which hasn’t got the match.
Can you please help me in giving me a workflow?
Thank you,

1 Like

Hi @CamiCat


Use path exists and pass the strfiles

And conditions are true

Use move file activity


1 Like

Hi Cami
In reference to this topic

With the following comment
— inside the loop use a if condition like this
If the above condition passes it will go rot THEN part which means there is similar filenamed files
Which we can mention In a message box activity
If not will go to ELSE part where we can mention no similar named files in a message box

Here in the ELSE part we can use a move file activity with source file property as item and mentio the destination folder to the path where you want to move

Hope this would help you
Cheers @CamiCat


What about it you want to match a files name to the folder and move but part of the file name will constantly change and the folders as well. For example if I have file is 1G23A and the folder is the same. The alphanumeric part will change. How can I incorporate it to an activity?

I think it should work.

Directory.GetFiles(FolderPath, “.”, SearchOption.AllDirectories).Where(Function(s) s.EndsWith(".pdf") Or s.EndsWith(".xml"))

That will not work because I need to match a specific alphanumeric text within the file. It doesn’t matter about the extension. For example. I have a file named student_a1bcde_2019 and i have a folder with the following name Class123_student_a1bcde_2019. The a1bcde will always be changing because it is an id and unique to the user. I can match the pattern with regex but how do I match a file to the folder and move it if the condition is met. I have no clue and I am stuck