Deleting files which have the same duplicate name in path except one

Hi

I am looking for a solution where I would like to delete all files with the same number in the name except one file should remain. In short: Doubles files should be deleted and one should be kept.

Hey!

We have similar thread… have a view on this

Regards,
NaNi

Hey @david.mitrovic

Get all the files from the folder with the filter condition of containing the number you have mentioned.

Directory.GetFiles()

Then you can loop through each file expect first and then delete those using Delete File activity.

Hope that helps.

Thanks
#nK

how can I skip the first entry in the if activity?

Hey!

If condition = True this will go to the then block…

In else block do then False process…

Regards,
NaNi

In the for-each once you get the files array just do the below,

arrFiles.Skip(1)

Directory.GetFiles(“C:\Users\Gangstar\OneDrive\Desktop\Test”).GroupBy(Function(F) F.split("_“c)(3).Split(” "c)(0)).Select(Function(g) g.First).Toarray