diff --git a/.vscode/launch.json b/.vscode/launch.json index 879078d..a5a016e 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -350,4 +350,34 @@ // If not Hog and Original image size resize face // New json file with known locations at original image size // Add person to metadata when saving to SaveFilteredOriginalImagesFromJLinksForOutputResolutions maybe SaveMappedForOutputResolutions -// GetFaceLocations \ No newline at end of file +// GetFaceLocations +// Stream stream; +// FileType fileType; +// const string abd = ".abd"; +// List jsonGroupFiles = GetFileCollection(jsonGroupFileCollection); +// foreach (string jsonGroupFile in jsonGroupFiles) +// File.Move(jsonGroupFile, string.Concat(jsonGroupFile, abd)); +// stream = new FileStream(file, FileMode.Open, FileAccess.Read, FileShare.Read); +// fileType = FileTypeDetector.DetectFileType(stream); +// stream.Close(); +// stream.Dispose(); +// if (fileType == FileType.Unknown) +// continue; +// if (!isUniqueFileName || string.IsNullOrEmpty(resultAllInOneKey)) +// { +// if (!isUniqueFileName && !string.IsNullOrEmpty(resultAllInOneKey)) +// File.Move(Path.Combine(resultAllInOneKey, fileName), Path.Combine(resultAllInOneKey, $"{fileName}.del")); +// resultAllInOneKey = string.Concat(jsonGroupDirectory, directoryName[length..]); +// } +// if (!jsonGroupFileCollection.TryGetValue(resultAllInOneKey, out keyValuePairs) || !keyValuePairs.TryGetValue(fileName, out collection)) +// fileAndJsonGroupFiles.Add(new FileAndJsonGroupFile(file, isUniqueFileName, Path.Combine(resultAllInOneKey, fileName), false)); +// else +// { +// foreach (string jsonGroupFile in collection) +// // File.Move(string.Concat(jsonGroupFile, abd), jsonGroupFile); +// fileAndJsonGroupFiles.Add(new FileAndJsonGroupFile(file, isUniqueFileName, jsonGroupFile, true)); +// } +// C:\Program Files\ImageMagick-7.1.0-Q16-HDRI>identify -format '%Q' "D:\7) Question\- - - Images\Mike Goolgle Photos 2014\-1507651551.jpg" +// '98' +// C:\Program Files\ImageMagick-7.1.0-Q16-HDRI>identify -format '%Q' "D:\7) Question\- - - Images\Mike Goolgle Photos 2014\197616258.jpg" +// '90' \ No newline at end of file diff --git a/Delete-By-Distinct/DeleteByDistinct.cs b/Delete-By-Distinct/DeleteByDistinct.cs index 599df34..12da881 100644 --- a/Delete-By-Distinct/DeleteByDistinct.cs +++ b/Delete-By-Distinct/DeleteByDistinct.cs @@ -34,11 +34,12 @@ public class DeleteByDistinct private static void Work(AppSettings appSettings, long ticks, ILogger log, string directory, string variable, ProgressBarOptions options, Dictionary>> fileSizeToCollection, bool logOnly) { string message; + long checkTicks; + long checkLength; string checkName; string deleteLog; int totalSeconds; FileInfo fileInfo; - DateTime checkDate; ProgressBar progressBar; List? fileNames; ConsoleKey? consoleKey = null; @@ -55,13 +56,18 @@ public class DeleteByDistinct progressBar.Tick(); foreach (string file in files) { + if (file.EndsWith(".id") || file.Contains("Rename")) + continue; fileInfo = new(file); if (fileInfo.Length < 100) continue; - if (!fileSizeToCollection.TryGetValue(fileInfo.Length, out fileTicksToNames)) + checkLength = fileInfo.Length; + // checkLength = (long)Math.Round((double)(fileInfo.Length / 1000)); + // checkLength = 1; + if (!fileSizeToCollection.TryGetValue(checkLength, out fileTicksToNames)) { - fileSizeToCollection.Add(fileInfo.Length, new()); - if (!fileSizeToCollection.TryGetValue(fileInfo.Length, out fileTicksToNames)) + fileSizeToCollection.Add(checkLength, new()); + if (!fileSizeToCollection.TryGetValue(checkLength, out fileTicksToNames)) throw new Exception(); } // if (!fileTicksToNames.TryGetValue(fileInfo.LastWriteTime.Ticks, out fileNames)) @@ -70,16 +76,17 @@ public class DeleteByDistinct // if (!fileTicksToNames.TryGetValue(fileInfo.LastWriteTime.Ticks, out fileNames)) // throw new Exception(); // } - // checkDate = new DateTime(ticks); - checkDate = new DateTime(fileInfo.LastWriteTime.Year, fileInfo.LastWriteTime.Month, fileInfo.LastWriteTime.Day); - if (!fileTicksToNames.TryGetValue(checkDate.Ticks, out fileNames)) + checkTicks = new DateTime(ticks).Ticks; + // checkTicks = new DateTime(fileInfo.LastWriteTime.Year, fileInfo.LastWriteTime.Month, fileInfo.LastWriteTime.Day).Ticks; + // checkTicks = 1; + if (!fileTicksToNames.TryGetValue(checkTicks, out fileNames)) { - fileTicksToNames.Add(checkDate.Ticks, new()); - if (!fileTicksToNames.TryGetValue(checkDate.Ticks, out fileNames)) + fileTicksToNames.Add(checkTicks, new()); + if (!fileTicksToNames.TryGetValue(checkTicks, out fileNames)) throw new Exception(); } - checkName = fileInfo.Name[..10]; - // checkName = fileInfo.Name.ToLower().Replace(".jpeg", ".jpg"); + // checkName = fileInfo.Name[..10]; + checkName = fileInfo.Name.ToLower().Replace(".jpeg", ".jpg"); if (fileNames.Contains(checkName)) deletedFiles.Add(file); else diff --git a/Delete-By-Distinct/appsettings.Development.json b/Delete-By-Distinct/appsettings.Development.json index 6acbfb2..c0d6168 100644 --- a/Delete-By-Distinct/appsettings.Development.json +++ b/Delete-By-Distinct/appsettings.Development.json @@ -1,5 +1,5 @@ { - "CompareRootDirectory": "D:/7) Question/- - - Videos A", + "CompareRootDirectory": "D:/7) Question/- - - Images", "Logging": { "LogLevel": { "Log4netProvider": "Debug" @@ -14,8 +14,8 @@ "Configuration": { "xRootDirectory": "D:/2) Images B/Corrupt", "xxRootDirectory": "D:/2) Images B/Not-Copy-Copy-45f4401", - "xxxRootDirectory": "D:/1) Images A/Images-45f4401", - "RootDirectory": "E:/3) Videos A/Device Videos 2_0_0_3 - Current", + "RootDirectory": "D:/1) Images A/Images-45f4401", + "xxxxRootDirectory": "E:/3) Videos A/Device Videos 2_0_0_3 - Current", "xxxxxRootDirectory": "E:/4) Videos B/Device Videos 2_0_0_3 - Current - Ignore", "VerifyToSeason": [] } diff --git a/Instance/appsettings.Development.json b/Instance/appsettings.Development.json index a1bd74b..9210594 100644 --- a/Instance/appsettings.Development.json +++ b/Instance/appsettings.Development.json @@ -19,8 +19,8 @@ "xPersonCharactersCopyCount": 2, "xRootDirectory": "D:/Tmp/phares/Pictures", "xxRootDirectory": "D:/Tmp/Phares/Compare/Corrupt", - "RootDirectory": "D:/2) Images B/Not-Copy-Copy-45f4401", - "xxxxRootDirectory": "D:/1) Images A/Images-45f4401", + "xxxRootDirectory": "D:/2) Images B/Not-Copy-Copy-45f4401", + "RootDirectory": "D:/1) Images A/Images-45f4401", "xxxxxRootDirectory": "D:/1) Images A/Images-45f4401/Facebook/=2022.3 Facebook", "SaveSortingWithoutPerson": true, "JLinks": [ @@ -38,12 +38,12 @@ "PropertyContentCollectionFiles": [], "RangeDaysDeltaTolerance": [ 0, - 2100, + 4100, 123456 ], "RangeDistanceTolerance": [ 0, - 0.3, + 0.6, 0.6 ], "RangeFaceAreaPermilleTolerance": [ diff --git a/Rename/Rename.cs b/Rename/Rename.cs index ac9b0c6..594f269 100644 --- a/Rename/Rename.cs +++ b/Rename/Rename.cs @@ -232,7 +232,7 @@ public class Rename continue; if (File.Exists(matchNginx.ConvertedPath)) continue; - files = Directory.GetFiles(matchNginx.ConvertedPath, "*", SearchOption.TopDirectoryOnly); + files = Directory.GetFiles(matchNginx.ConvertedPath, "*", SearchOption.AllDirectories); if (files.All(l => l.EndsWith(".id"))) { foreach (string file in files) @@ -258,6 +258,8 @@ public class Rename message = $"{i}) Renaming files"; files = i == 2 ? allFiles.ToArray() : (from l in allFiles where l.Contains("Rename") select l).ToArray(); progressBar = new(files.Length, message, options); + if (!files.Any()) + continue; (renameCollection, distinctCount) = RenameFilesInDirectory(progressBar, files); foreach ((FileHolder fileHolder, string to) in renameCollection) { diff --git a/Rename/appsettings.Development.json b/Rename/appsettings.Development.json index 6a45fbc..aea16aa 100644 --- a/Rename/appsettings.Development.json +++ b/Rename/appsettings.Development.json @@ -1,5 +1,5 @@ { - "ComparePathsFile": "C:/Users/mikep/AppData/Local/PharesApps/Drag-Drop-Explorer/2023_01/638082668201867717.json", + "ComparePathsFile": "C:/Users/mikep/AppData/Local/PharesApps/Drag-Drop-Explorer/2023_02/638089737585839769.json", "Logging": { "LogLevel": { "Log4netProvider": "Debug"