Rename all sub directories directories and

delete by distinct improvements
This commit is contained in:
2023-01-10 19:04:49 -07:00
parent be8829bbcd
commit fbaafe0137
6 changed files with 60 additions and 21 deletions

View File

@ -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

View File

@ -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": []
}