Check if file name is the same across two folder

Hello,

I have two folders - and need to copy those that have the same name into another folder. Folder A has 10 files and I need to find the 10 with the same name in Folder B and then copy them to another folder.

Documents in Folder A and B have different extensions. How can I check these two regardless of extension

Hi,

Can you try the following expressions? (Use Assign Activity)

`arrFilesInA = System.IO.Directory.GetFiles(strFolderA,"*.*")`
`arrFilesWithoutExtInB = System.IO.Directory.GetFiles(strFolderB,"*.*").Select(Function(x) System.IO.Path.GetFileNameWithoutExtension(x)).ToArray`
`arrFilesMatched = arrFilesInA.Where(Function(x) arrFilesWithoutExtInB.Contains(System.IO.Path.GetFileNameWithoutExtension(x))).ToArray`

Finally, arrFilesMatched will have files which you want to copy to another.

Regards,

For Folder A
Assign Array1:Directory.GetFiles(“FolderB Path”)
In For Each Item=Directory.GetFiles(“FolderA Path”)
If Array1.contains(Path.GetFileNameWithoutExtension(Item.Tostring))
Then Copy File else Leave it Blank

1 Like

Actually, how do i ignore extensions in both folders?

One is all text and the other folder is jpg or pdf

See below

How do I go from the final assign to copying?

I’m running FileMatch through for each but getting an error when going to copy the file. How can this be fixed

Hi,

I’ll attached a sample as the following. This workflow copy files in Data\A which there is same name in Data\B to Data\Dist folder.
Can you try this?

Sample20200111.zip (15.0 KB)

Regards,

1 Like

Which error ?

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