private static void SyncPaths(string pathFrom, string pathTo) { Console.WriteLine("Syncing"); Console.WriteLine($" {pathFrom.Abbreviate(70, 4)}"); Console.WriteLine(" to"); Console.WriteLine($" {pathTo.Abbreviate(70, 4)}"); Console.WriteLine(); var filesFrom = JpegInfo.GetFiles(pathFrom).Where(x => x.Jpeg && x.Width == 1920 && x.Height == 1080); var filesTo = JpegInfo.GetFiles(pathTo).Where(x => x.Jpeg); //#if DEBUG // Stopwatch sw = Stopwatch.StartNew(); //#endif // var filesNew = filesFrom.Where(x => filesTo.All(y => !x.Similar(y))); //#if DEBUG // sw.Stop(); // Console.WriteLine("Time taken: {0}ms", sw.Elapsed.TotalMilliseconds); //Stopwatch sw2 = Stopwatch.StartNew(); //var filesNew2 = filesFrom.Where(x => filesTo.All(y => y.Hash != x.Hash)); //sw2.Stop(); //#if DEBUG // // Stopwatch sw3 = Stopwatch.StartNew(); var filesNew3 = filesFrom.Where(x => filesTo.All(y => y != x)); // sw3.Stop(); //Console.WriteLine("Time taken: {0}ms", sw.Elapsed.TotalMilliseconds); //Console.WriteLine("Time taken: {0}ms", sw2.Elapsed.TotalMilliseconds); // Console.WriteLine("Time taken: {0}ms", sw3.Elapsed.TotalMilliseconds); // Console.WriteLine("filenew: " + filesNew.Count()); // Console.WriteLine("filenew2: " + filesNew2.Count()); Console.WriteLine("filenew3: " + filesNew3.Count()); // #endif if (filesNew3.Any()) { Console.WriteLine("Copying:"); foreach (var file in filesNew3) { Console.WriteLine(file.ToString); var filePathFrom = Path.Combine(pathFrom, file.FileName); var filePathTo = Path.Combine(pathTo, file.FileName + ".jpg"); File.Copy(filePathFrom, filePathTo); } } else { Console.WriteLine("No new files"); } Console.WriteLine(); }
private static void PrintPathInfo(string pathInfo) { Console.WriteLine("Reading from " + pathInfo); var files = JpegInfo.GetFiles(pathInfo); foreach (var file in files) { Console.WriteLine(file.ToString); } }