/ Published in: C#
simple LINQ and a Left extension method
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.IO; namespace CentreFolderDeduper { class Program { static void Main(string[] args) { String[] centreFolders = Directory.GetDirectories(args[0]); foreach(var centreFolder in centreFolders) { if (centreFolder.IndexOf('-') != -1) { centres.Add(centreFolder.Left(centreFolder.IndexOf('-'))); } } var duplicateFolders = from f in centres group f by f.ToString() into g where g.Count() > 1 Console.WriteLine(duplicateFolders.Count()); ObjectDumper.Write(duplicateFolders); Console.ReadKey(); } } }