Moving files that contain part of a folder name to that specific Folder

Hello everyone,

I have a small issue that’s driving me crazy because I don’t know how to fix it!

Let me give you an example : The file that I am trying to move is named “Nicusor.jpg” , while the folder that I am trying to move it to is called “Nicusor Dan”. The thing that makes this task a little complicated is that this being a framework project, I have multiple files and folders named in the same manner!

There are 8 folders in total with full names ( just like the example above) and 25 files (images) that need to be moved in the appropiate folder! What I tried doing was storing all the folder names inside an array, like arrFolders = Directory.GetDirectories(“…\ProjectOutputFolder”) and then checking if arrFolders.Contains(name.ToString)

But I don’t know how to move the file in the proper folder after checking!

Thanks in advance…


In “To” can’t you set the value : Path.combine(arrFolder(name),“Nicusor.jpg”)

Hey @alex_T,

Have a look on this thread.


Hey, I tried it, but it does not work… Thanks for your time anyway!

I did take a look at that thread… even tried a few solutions but none seemed to really apply.

I came up with the idea of using a switch for each of the cases, but I’m not sure what to type into the expression field

the contains method from an array will check for the entire item but not for a part within the item string


Such a check we could implement e.g.

But from your description we do feel that following is needed

Based on the filename the corresponding folderpath should be calculated
But the filetypeextension is to ignore


and based on the retruned result the destination FullFilePAth can be constructed e.g. with Path.Combine