Rename all sub directories directories and
delete by distinct improvements
This commit is contained in:
@ -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
|
||||
|
Reference in New Issue
Block a user