Moved from Google Photos
This commit is contained in:
parent
0ca53436e5
commit
aec9d0a55d
@ -59,13 +59,13 @@ public class DateGroup
|
||||
string aPropertySingletonDirectory = Path.Combine(aResultsFullGroupDirectory, "{}");
|
||||
if (!Directory.Exists(aPropertySingletonDirectory))
|
||||
_ = Directory.CreateDirectory(aPropertySingletonDirectory);
|
||||
(int f, Container[] containers) = Shared.Models.Stateless.Methods.IContainer.GetContainers(propertyConfiguration, aPropertySingletonDirectory);
|
||||
(int t, Container[] containers) = Shared.Models.Stateless.Methods.IContainer.GetContainers(propertyConfiguration, aPropertySingletonDirectory);
|
||||
A_Property propertyLogic = GetPropertyLogic(reverse, aResultsFullGroupDirectory, aResultsFullGroupDirectory);
|
||||
if (propertyLogic.ExceptionsDirectories.Any())
|
||||
throw new Exception();
|
||||
if (propertyConfiguration.PopulatePropertyId && (configuration.ByCreateDateShortcut || configuration.ByHash) && Shared.Models.Stateless.Methods.IProperty.Any(containers))
|
||||
{
|
||||
propertyLogic.SavePropertyParallelWork(ticks, containers);
|
||||
propertyLogic.SavePropertyParallelWork(ticks, t, containers);
|
||||
if (appSettings.MaxDegreeOfParallelism < 2)
|
||||
ticks = LogDelta(ticks, nameof(A_Property.SavePropertyParallelWork));
|
||||
if (propertyLogic.ExceptionsDirectories.Any())
|
||||
@ -213,10 +213,10 @@ public class DateGroup
|
||||
throw new Exception();
|
||||
dateTimes = new() { item.ImageFileHolder.LastWriteTime.Value };
|
||||
}
|
||||
if (item.ImageFileHolder.LastWriteTime is not null && item.Property is null)
|
||||
dateTime = item.ImageFileHolder.LastWriteTime.Value;
|
||||
else if (item.Property is not null && item.Property.DateTimeOriginal is not null)
|
||||
if (item.Property is not null && item.Property.DateTimeOriginal is not null)
|
||||
dateTime = item.Property.DateTimeOriginal.Value;
|
||||
else if (item.ImageFileHolder.LastWriteTime is not null && item.Property is null)
|
||||
dateTime = item.ImageFileHolder.LastWriteTime.Value;
|
||||
else
|
||||
dateTime = Shared.Models.Stateless.Methods.IProperty.GetMinimumDateTime(item.Property);
|
||||
day = dateTime.ToString("MM-dd");
|
||||
|
@ -19,7 +19,7 @@
|
||||
"xxxRootDirectory": "F:/Tmp/Phares/Compare/Not-Copy-Copy-1e85c0ba",
|
||||
"xxxxRootDirectory": "C:/Tmp/Phares/Compare/Not-Copy-Copy-1e85c0ba",
|
||||
"xxxxxRootDirectory": "F:/Tmp/Phares/2022-11-03-DCIM/DCIM/100D3400 2022",
|
||||
"RootDirectory": "D:/1) Images A/Images-1e85c0ba/zzz Mackenzie Laptop !9/_"
|
||||
"RootDirectory": "D:/1) Images A/Images-1e85c0ba/_"
|
||||
}
|
||||
}
|
||||
}
|
@ -652,7 +652,7 @@ public partial class DlibDotNet
|
||||
sourceDirectoryChanges.Clear();
|
||||
anyNullOrNoIsUniqueFileName = filteredItems.Any(l => !l.IsUniqueFileName);
|
||||
totalSeconds = (int)Math.Floor(new TimeSpan(DateTime.Now.Ticks - ticks).TotalSeconds);
|
||||
message = $"{i + 1:000} [{filteredItems.Length:000} collectionB] / {containersLength:000} - {total} / {t} total collectionB - {totalSeconds} total second(s) - {outputResolution} - {container.SourceDirectory}";
|
||||
message = $"{i + 1:000} [{filteredItems.Length:000}] / {containersLength:000} - {total} / {t} total - {totalSeconds} total second(s) - {outputResolution} - {container.SourceDirectory}";
|
||||
if (_Configuration.LoadOrCreateThenSaveImageFacesResultsForOutputResolutions.Contains(outputResolution))
|
||||
_Faces.SetAngleBracketCollection(dResultsFullGroupDirectory, container.SourceDirectory);
|
||||
if (_Configuration.SaveFaceLandmarkForOutputResolutions.Contains(outputResolution))
|
||||
|
@ -284,7 +284,7 @@ public class A_Property
|
||||
fileInfo = new(Path.Combine(angleBracket.Replace("<>", "{}"), $"{item.ImageFileHolder.NameWithoutExtension}{item.ImageFileHolder.ExtensionLowered}.json"));
|
||||
else
|
||||
fileInfo = new(Path.Combine(_JsonGroups["{}"][directoryIndex], $"{item.ImageFileHolder.NameWithoutExtension}{item.ImageFileHolder.ExtensionLowered}.json"));
|
||||
List<DateTime> dateTimes = (from l in sourceDirectoryFileTuples where changesFrom.Contains(l.Item1) select l.Item2).ToList();
|
||||
List<DateTime> dateTimes = (from l in sourceDirectoryFileTuples where l is not null && changesFrom.Contains(l.Item1) select l.Item2).ToList();
|
||||
if (_Configuration.ForcePropertyLastWriteTimeToCreationTime && !fileInfo.Exists && File.Exists(Path.ChangeExtension(fileInfo.FullName, ".delete")))
|
||||
{
|
||||
File.Move(Path.ChangeExtension(fileInfo.FullName, ".delete"), fileInfo.FullName);
|
||||
@ -463,16 +463,18 @@ public class A_Property
|
||||
SetAngleBracketCollection(aResultsFullGroupDirectory, sourceDirectory, anyNullOrNoIsUniqueFileName);
|
||||
}
|
||||
|
||||
public void SavePropertyParallelWork(long ticks, Container[] containers)
|
||||
public void SavePropertyParallelWork(long ticks, int t, Container[] containers)
|
||||
{
|
||||
if (_Log is null)
|
||||
throw new NullReferenceException(nameof(_Log));
|
||||
int total = 0;
|
||||
string message;
|
||||
int totalSeconds;
|
||||
Container container;
|
||||
bool anyNullOrNoIsUniqueFileName;
|
||||
List<Exception> exceptions = new();
|
||||
int containersCount = containers.Length;
|
||||
int containersLength = containers.Length;
|
||||
const string outputResolution = "Original";
|
||||
List<Tuple<string, DateTime>> sourceDirectoryChanges = new();
|
||||
string propertyRoot = IResult.GetResultsGroupDirectory(_Configuration, nameof(A_Property));
|
||||
for (int i = 0; i < containers.Length; i++)
|
||||
@ -486,7 +488,7 @@ public class A_Property
|
||||
anyNullOrNoIsUniqueFileName = container.Items.Any(l => !l.IsUniqueFileName);
|
||||
SetAngleBracketCollection(container.SourceDirectory, anyNullOrNoIsUniqueFileName);
|
||||
totalSeconds = (int)Math.Truncate(new TimeSpan(DateTime.Now.Ticks - ticks).TotalSeconds);
|
||||
message = $"{i + 1:000} / {containersCount:000}) {container.Items.Count:000} file(s) - {totalSeconds} total second(s) - {container.SourceDirectory}";
|
||||
message = $"{i + 1:000} [{container.Items.Count:000}] / {containersLength:000} - {total} / {t} total - {totalSeconds} total second(s) - {outputResolution} - {container.SourceDirectory}";
|
||||
SavePropertyParallelWork(exceptions, sourceDirectoryChanges, container, container.Items, message);
|
||||
foreach (Exception exception in exceptions)
|
||||
_Log.Error(string.Concat(container.SourceDirectory, Environment.NewLine, exception.Message, Environment.NewLine, exception.StackTrace), exception);
|
||||
@ -504,6 +506,7 @@ public class A_Property
|
||||
}
|
||||
_Log.Information(". . .");
|
||||
}
|
||||
total += container.Items.Count;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -25,6 +25,7 @@ public class Rename
|
||||
{ }
|
||||
if (console is null)
|
||||
{ }
|
||||
bool any = false;
|
||||
_AppSettings = appSettings;
|
||||
_IsEnvironment = isEnvironment;
|
||||
long ticks = DateTime.Now.Ticks;
|
||||
@ -46,16 +47,29 @@ public class Rename
|
||||
MatchNginx[]? matchNginxCollection = JsonSerializer.Deserialize<MatchNginx[]>(json);
|
||||
if (matchNginxCollection is null)
|
||||
throw new NullReferenceException(nameof(matchNginxCollection));
|
||||
if (matchNginxCollection.Length == 0 && matchNginxCollection[0].ConvertedPath.Contains("~~~"))
|
||||
MoveMatches(matchNginxCollection[0]);
|
||||
else if (matchNginxCollection.All(l => l.Name.StartsWith("#")) || matchNginxCollection.All(l => l.Name.StartsWith(" #")) || matchNginxCollection.All(l => l.Name.StartsWith("=20")) || matchNginxCollection.All(l => l.Name.StartsWith("#20")))
|
||||
Rename2000(matchNginxCollection);
|
||||
else if (matchNginxCollection.Any())
|
||||
if (matchNginxCollection.Any())
|
||||
{
|
||||
List<string> lines = RenameFilesInDirectories(log, matchNginxCollection);
|
||||
File.WriteAllLines($"D:/Tmp/Phares/{DateTime.Now.Ticks}.tsv", lines);
|
||||
if (comparePathRoot != Path.GetPathRoot(matchNginxCollection[0].ConvertedPath))
|
||||
_ = Shared.Models.Stateless.Methods.IPath.DeleteEmptyDirectories(comparePathRoot);
|
||||
bool deleted;
|
||||
for (int i = 1; i < 5; i++)
|
||||
{
|
||||
deleted = Shared.Models.Stateless.Methods.IPath.DeleteEmptyDirectories(matchNginxCollection.First().ConvertedPath);
|
||||
if (deleted && !any)
|
||||
any = true;
|
||||
}
|
||||
}
|
||||
if (!any)
|
||||
{
|
||||
if (matchNginxCollection.Length == 0 && matchNginxCollection[0].ConvertedPath.Contains("~~~"))
|
||||
MoveMatches(matchNginxCollection[0]);
|
||||
else if (matchNginxCollection.All(l => l.Name.StartsWith("#")) || matchNginxCollection.All(l => l.Name.StartsWith(" #")) || matchNginxCollection.All(l => l.Name.StartsWith("=20")) || matchNginxCollection.All(l => l.Name.StartsWith("#20")))
|
||||
Rename2000(log, matchNginxCollection);
|
||||
else if (matchNginxCollection.Any())
|
||||
{
|
||||
List<string> lines = RenameFilesInDirectories(log, matchNginxCollection);
|
||||
File.WriteAllLines($"D:/Tmp/Phares/{DateTime.Now.Ticks}.tsv", lines);
|
||||
if (comparePathRoot != Path.GetPathRoot(matchNginxCollection[0].ConvertedPath))
|
||||
_ = Shared.Models.Stateless.Methods.IPath.DeleteEmptyDirectories(comparePathRoot);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -262,11 +276,13 @@ public class Rename
|
||||
return results;
|
||||
}
|
||||
|
||||
private static void Rename2000(MatchNginx[] matchNginxCollection)
|
||||
private static void Rename2000(ILogger log, MatchNginx[] matchNginxCollection)
|
||||
{
|
||||
string name;
|
||||
string check;
|
||||
string? directoryName;
|
||||
log.Information("Enter a suffix if any");
|
||||
string? suffix = System.Console.ReadLine();
|
||||
foreach (MatchNginx matchNginx in matchNginxCollection)
|
||||
{
|
||||
name = matchNginx.Name.Trim();
|
||||
@ -276,7 +292,7 @@ public class Rename
|
||||
if (directoryName is null)
|
||||
continue;
|
||||
if (name.StartsWith("=20") || name.StartsWith("#20"))
|
||||
check = Path.Combine(directoryName, name[1..]);
|
||||
check = Path.Combine(directoryName, $"{name[1..]}{suffix}");
|
||||
else
|
||||
check = Path.Combine(directoryName, $"zzz {name[5..]}");
|
||||
if (Directory.Exists(check) || File.Exists(check))
|
||||
|
@ -106,7 +106,7 @@ internal abstract class Property
|
||||
if (result is not null)
|
||||
break;
|
||||
}
|
||||
if (result is not null && result.Value)
|
||||
if (result is not null && !result.Value)
|
||||
break;
|
||||
}
|
||||
return new(result, results);
|
||||
|
Loading…
x
Reference in New Issue
Block a user