How to check if the filename is same on the other filename in the other folder?

How to check if the filename is same on the other filename in the other folder?

Hello @fniedez
Use File Exist activity. It will result in boolean

1 Like

HI,

Hope the following helps you.

image

System.IO.File.Exists(System.IO.Path.Combine(otherFolder,System.IO.Path.GetFileName(targetFile)))

Regards,

1 Like

Hello @Yoichi ,

What if I have two different zip file and I need to extract it with subfolder? After the extraction I need to check ALL the .cfg file, if the file is existing into another folder (with the same name)?

Here is the sample:
BeforeExample.zip (1.2 KB)
AfterExample.zip (1.3 KB)

Regards,
France

Hello

Also @Yoichi I need to append line the output.

Regards,
France

HI,

In this case, we need to extract both zip files, then compare extracted files.
For now, can you try the following workflow?

Sample20221221-1aL.zip (6.5 KB)

This workflow outputs file list of exists in both and only in either one to Output panel.

Hope this helps you.

Regards,

Hello @Yoichi

Your file doesn’t work, if I run the xaml file it stock on the running.

Hi,

Is there File Dialog behind other window? The above workflow ask which zip file is used, twice.

Regards,

Hello,

There is no File Dialog behind other window.

HI

Can you try the following. I removed OpenDialog and set input as BeforeExample.zip and AfterExample.zip

Sample20221221-1aLv2.zip (6.3 KB)

Please check output panel as result.

Regards,

Hello @Yoichi

It works but there’s no output that checks if before are the same to after file = true then if not return false.

I sent some message to you

Thanks,
France

@Gokul_Jayakumar can you please elaborate your answer?

@fniedez,

You can try to get filenames from both directories and compare it as List.

This will give you a list of filename as string format from the Folder 1, you have to assign this to a List(Of string) as “lstFolder1Files” variable in your workflow. Same way do it for Folder2 as well in “lstFolder2Files”.

New System.IO.DirectoryInfo("FolderPath1").GetFiles().Select(Function(file) file.Name).ToList()

lstFolder1Files.Intersect(lstFolder2Files) - this will give your the filenames which are all same in both directories

@sarathi125

What activity should I place this code: lstFolder1Files.Intersect(lstFolder2Files) ?

Regards,
France

CompareFiles.xaml (5.0 KB)

Try with this workflow

@sarathi125

How can I determine if it’s True when all the files are the same and False when there’s a file that are not the same?

Regards,
France

@fniedez,

Based on the 3rd output list “lstMatchingFiles”, if it is count is greater than one, you can see the matching filename, if it has 0 items then no filename is matching between two folders.

@sarathi125

How can I even know or see the output?

@fniedez,

You can use ForEach and print the final list “lstMatchingFiles”

@sarathi125

there’s no output, please can you do that in the activity?