# Checking duplicate files in folder

**URL:** <https://forum.uipath.com/t/checking-duplicate-files-in-folder/454470>\
**Category:** Automation Starter\
**Tags:** files, studio, activities\
**Created:** [July 7, 2022, 4:15am UTC](https://forum.uipath.com/t/checking-duplicate-files-in-folder/454470 "2022-07-07T04:15:56Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Zaw\_Win\_Htun1](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/zaw_win_htun1/32/240540_2.png) [@Zaw\_Win\_Htun1](https://forum.uipath.com/u/Zaw_Win_Htun1)\
**Post date:** [July 7, 2022, 4:15am UTC](https://forum.uipath.com/t/checking-duplicate-files-in-folder/454470/1 "2022-07-07T04:15:56Z")

</div>

Hello experts

I want to check files in two folders and if the files name are the same, I will delete the files in the folder and if the files name are different, I will copy the files to another folder.  
How to check the duplicate files in two folder? If the file names are the same, the file will be deleted and if the file names are different, the file will be copied to another folder.  
I have the files in download folder like this:  
 ![image](https://global.discourse-cdn.com/uipath/original/4X/1/7/9/179cf436d7351b8e58d2949a26d63dfecd4fa2f1.png)

I have the files in original folder like this:  
 ![image](https://global.discourse-cdn.com/uipath/original/4X/a/f/d/afdd917ba079a46b49f60894f1cab538be2c38c2.png)

Above the scanerio, I want to copy the files all the files except NTV\_UAT\_0001624.xlsx to original folder and delete the file name NTV\_UAT\_0001624.xlsx in download folder.  
If you have solutions for this, please share with me.

---

<div class="post-metadata">

**Author:** ![THIRU\_NANI](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/thiru_nani/32/317561_2.png) [@THIRU\_NANI](https://forum.uipath.com/u/THIRU_NANI)\
**Post date:** [July 7, 2022, 4:39am UTC](https://forum.uipath.com/t/checking-duplicate-files-in-folder/454470/2 "2022-07-07T04:39:48Z")

</div>

Hi!

Try this below:

```auto
Assign FolderPath1 = "Desktop\FirstFolder\"

```

**Where FolderPath1 is a string type variable**

```auto
Assign FolderPath2 = "Desktop\SecondFolder\"

```

**Where FolderPath2 is a string type variable**

```auto
Assign Arr_Folder1 = Directory.GetFiles(Folderpath1,"*.xlxx")

```

**Where Arr\_Folder1 is a Array(string) type variable**

```auto
Assign Arr_Folder2 = Directory.GetFiles(Folderpath2,"*.xlxx")

```

**Where Arr\_Folder2 is a Array(string) type variable**

Take one For each activity and pass the **Arr\_Folder1**  
Take one more for each activity and pass the **Arr\_Folder2**

Now take one if activity… Pass the condition like this

```auto
Item1.ToString.Trim.ToLower.Equals(item2.ToString.Trim.ToLower)

```

In then Block Use Delete file Activity

In else block keep Copy Excel File activity

That’s it

Try this and let me know

Regards,  
NaNi

---

<div class="post-metadata">

**Author:** ![Zaw\_Win\_Htun1](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/zaw_win_htun1/32/240540_2.png) [@Zaw\_Win\_Htun1](https://forum.uipath.com/u/Zaw_Win_Htun1)\
**Post date:** [July 7, 2022, 5:00am UTC](https://forum.uipath.com/t/checking-duplicate-files-in-folder/454470/3 "2022-07-07T05:00:46Z")

</div>

can u please share me the workflow file and at the first time, there is no file in original floder.  
At the first time runs, does the condition also work?  
And also if there is another solution to process as fast as possible, please also share with me.Thanks.

---

<div class="post-metadata">

**Author:** ![THIRU\_NANI](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/thiru_nani/32/317561_2.png) [@THIRU\_NANI](https://forum.uipath.com/u/THIRU_NANI)\
**Post date:** [July 7, 2022, 5:06am UTC](https://forum.uipath.com/t/checking-duplicate-files-in-folder/454470/4 "2022-07-07T05:06:45Z")

</div>

Hey!

Without having the files in a folder how can we compare the files with different folders?

If those duplicates files placed in a single folder we can’t compare because… The folder won’t accept the duplication…

**Example:**

File: Nani.xlsx  
DuplicateFile: Nani-Copy.xlsx

The file will modify like this else file explorer asks us to replace or skip the existing file…

Could you please share us the snap of input folder path which is having files?

Regards,  
NaNi

---

<div class="post-metadata">

**Author:** ![Rahul\_Unnikrishnan](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/rahul_unnikrishnan/32/464046_2.png) [@Rahul\_Unnikrishnan](https://forum.uipath.com/u/Rahul_Unnikrishnan)\
**Post date:** [July 7, 2022, 5:18am UTC](https://forum.uipath.com/t/checking-duplicate-files-in-folder/454470/5 "2022-07-07T05:18:45Z")

</div>

Hello @Zaw_Win_Htun1

It would be better if you can share the process which you are automating and the requirement here.  
This comparison maybe redesigned if you can elaborate the exact flow

---

<div class="post-metadata">

**Author:** ![Barry\_Rock](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/barry_rock/32/334331_2.png) [@Barry\_Rock](https://forum.uipath.com/u/Barry_Rock)\
**Post date:** [September 17, 2022, 1:37am UTC](https://forum.uipath.com/t/checking-duplicate-files-in-folder/454470/6 "2022-09-17T01:37:52Z")

</div>

For deleting duplicated files, I was using DuplicateFilesDeleter.
