Rename all sub directories directories and
delete by distinct improvements
This commit is contained in:
parent
be8829bbcd
commit
fbaafe0137
32
.vscode/launch.json
vendored
32
.vscode/launch.json
vendored
@ -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
|
||||
// GetFaceLocations
|
||||
// Stream stream;
|
||||
// FileType fileType;
|
||||
// const string abd = ".abd";
|
||||
// List<string> 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'
|
@ -34,11 +34,12 @@ public class DeleteByDistinct
|
||||
private static void Work(AppSettings appSettings, long ticks, ILogger log, string directory, string variable, ProgressBarOptions options, Dictionary<long, Dictionary<long, List<string>>> fileSizeToCollection, bool logOnly)
|
||||
{
|
||||
string message;
|
||||
long checkTicks;
|
||||
long checkLength;
|
||||
string checkName;
|
||||
string deleteLog;
|
||||
int totalSeconds;
|
||||
FileInfo fileInfo;
|
||||
DateTime checkDate;
|
||||
ProgressBar progressBar;
|
||||
List<string>? 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
|
||||
|
@ -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": []
|
||||
}
|
||||
|
@ -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": [
|
||||
|
@ -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)
|
||||
{
|
||||
|
@ -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"
|
||||
|
Loading…
x
Reference in New Issue
Block a user