static int Main(string[] args) { if (args.Length == 0) { Usage(); return((int)ExitCode.NoTargets); } var targets = args.ToList <String>(); var finder = new DupeFinder(targets); finder.ExamineFiles(); _logger.Info("Starting to generate output file"); // Write out the hash dupes. JsonSerializer serializer = new JsonSerializer(); serializer.Converters.Add(new JavaScriptDateTimeConverter()); serializer.Formatting = Formatting.Indented; serializer.NullValueHandling = NullValueHandling.Ignore; using (StreamWriter sw = new StreamWriter("duplicate-hashes.json")) using (JsonWriter writer = new JsonTextWriter(sw)) { serializer.Serialize(writer, finder.DuplicateHashes()); } using (StreamWriter sw = new StreamWriter("all-directories.json")) using (JsonWriter writer = new JsonTextWriter(sw)) { serializer.Serialize(writer, finder.AllDirectories); } _logger.Info("Found {0} duplicated files", finder.DuplicateHashes().Count()); // Find all directories that are mostly dupes or have a very large number of dupes. foreach (var entry in finder.AllDirectories) { if ((float)(entry.Value.DuplicateCount) / entry.Value.FileCount >= 0.8f) { Console.WriteLine("{0} has {1}% dupes", entry.Key, ((float)(entry.Value.DuplicateCount) / entry.Value.FileCount) * 100); } else if (entry.Value.DuplicateCount >= 100) { Console.WriteLine("{0} has {1} dupes", entry.Key, entry.Value.DuplicateCount); } } Console.ReadLine(); return((int)ExitCode.Success); }
static void Main(string[] args) { //Error handling? WTF is that? //Nothing can possibly go wrong! :-) DupeFinder dupeFinder = new DupeFinder(); bool batch = false; for (int x = 0; x < args.Length; x++) { switch (args[x].ToLower()) { case "/settings": if (!dupeFinder.SettingsFromXML(args[x + 1])) { Console.WriteLine("Problem reading or parsing settings: " + args[x + 1]); DisplayUseage(); return; } x++; break; case "/batch": batch = true; break; default: Console.WriteLine("Unknown argument:" + args[x]); DisplayUseage(); return; } } //Build list of files to scan for dupes Console.WriteLine("Building file list..."); dupeFinder.BuildFileList(); //Find the dupes, biased towards HD and the prefered channel list Console.WriteLine("Searching for duplicate items..."); dupeFinder.FindDupes(); //This generates a batch file that does the dirty work if (batch) { Console.WriteLine("Generating batch file and saving it to the desktop..."); dupeFinder.DumpBatchFile(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Desktop), @"nukedupes.bat")); } else { dupeFinder.DeleteDupes(); } }