Mass push
This commit is contained in:
@ -36,8 +36,9 @@ public class DateGroup
|
||||
_FileKeyValuePairs = new List<KeyValuePair<string, string>>();
|
||||
_FilePropertiesKeyValuePairs = new Dictionary<string, List<Tuple<string, Shared.Models.Property>>>();
|
||||
Property.Models.Configuration propertyConfiguration = Property.Models.Binder.Configuration.Get(isEnvironment, configurationRoot);
|
||||
Property.Models.Configuration.Verify(propertyConfiguration, requireExist: true);
|
||||
Models.Configuration configuration = Models.Binder.Configuration.Get(isEnvironment, configurationRoot, propertyConfiguration);
|
||||
_Log.Information(propertyConfiguration.RootDirectory);
|
||||
Property.Models.Configuration.Verify(propertyConfiguration, requireExist: true);
|
||||
Verify(configuration);
|
||||
bool reverse = false;
|
||||
_Configuration = configuration;
|
||||
@ -141,8 +142,6 @@ public class DateGroup
|
||||
check += 1;
|
||||
if (configuration.ByHash)
|
||||
check += 1;
|
||||
if (configuration.ByNone)
|
||||
check += 1;
|
||||
if (configuration.BySeason)
|
||||
check += 1;
|
||||
if (configuration.ByWeek)
|
||||
@ -256,18 +255,15 @@ public class DateGroup
|
||||
if (matches is not null && matches.Any())
|
||||
break;
|
||||
}
|
||||
matches ??= Array.Empty<string>();
|
||||
foreach (Item item in filteredItems)
|
||||
{
|
||||
if (item.Property is null || (_Configuration.PropertyConfiguration.PopulatePropertyId && item.Property.Id is null))
|
||||
continue;
|
||||
directoryNames.Clear();
|
||||
destinationCollection = new();
|
||||
_ = destinationDirectoryName.Clear();
|
||||
minimumDateTime = Shared.Models.Stateless.Methods.IProperty.GetMinimumDateTime(item.Property);
|
||||
day = minimumDateTime.Value.ToString("MM-dd");
|
||||
month = minimumDateTime.Value.ToString("MMMM");
|
||||
if (item.Property.Id is null)
|
||||
if (item.Property?.Id is null)
|
||||
{
|
||||
flag = '#';
|
||||
isWrongYear = null;
|
||||
@ -294,6 +290,8 @@ public class DateGroup
|
||||
seasonValue = $".{season}";
|
||||
if (isWrongYear is null || !isWrongYear.Value)
|
||||
year = $"{flag}{minimumDateTime.Value:yyyy}{seasonValue}";
|
||||
else if (matches is null || matches.Length < 3)
|
||||
year = "----";
|
||||
else
|
||||
{
|
||||
if (matches[0][0] != '~')
|
||||
@ -303,9 +301,7 @@ public class DateGroup
|
||||
}
|
||||
topDirectoryName = Path.GetFileName(topDirectory);
|
||||
weekOfYear = calendar.GetWeekOfYear(minimumDateTime.Value, CalendarWeekRule.FirstDay, DayOfWeek.Sunday).ToString("00");
|
||||
if (_Configuration.ByNone)
|
||||
directoryNames.Clear();
|
||||
else if (_Configuration.ByHash)
|
||||
if (_Configuration.ByHash)
|
||||
directoryNames.Add($"{year} {seasonName}");
|
||||
else if (_Configuration.BySeason && topDirectoryName.Length == 1 && topDirectoryName[0] == '_')
|
||||
directoryNames.Add($"{year} {seasonName}");
|
||||
@ -328,7 +324,7 @@ public class DateGroup
|
||||
{
|
||||
foreach (string sourceDirectoryNameSegment in topDirectorySegments)
|
||||
{
|
||||
if (matches.Contains(sourceDirectoryNameSegment))
|
||||
if (matches is not null && matches.Contains(sourceDirectoryNameSegment))
|
||||
_ = destinationDirectoryName.Append(year);
|
||||
else
|
||||
_ = destinationDirectoryName.Append(sourceDirectoryNameSegment);
|
||||
@ -343,14 +339,19 @@ public class DateGroup
|
||||
throw new Exception();
|
||||
}
|
||||
}
|
||||
if (!_Configuration.ByHash || item.Property.Id is null)
|
||||
if (!_Configuration.ByHash || item.Property?.Id is null)
|
||||
fileName = item.ImageFileHolder.Name;
|
||||
else
|
||||
fileName = $"{item.Property.Id.Value}{item.ImageFileHolder.ExtensionLowered}";
|
||||
destinationCollection.Add(destinationDirectory);
|
||||
destinationCollection.AddRange(directoryNames);
|
||||
destinationCollection.Add(fileName);
|
||||
results.Add(new(item, item.Property.LastWriteTime.Ticks, minimumDateTime.Value.Ticks, destinationCollection.ToArray()));
|
||||
if (item.ImageFileHolder.LastWriteTime is null)
|
||||
continue;
|
||||
if (item.Property is not null)
|
||||
results.Add(new(item, item.Property.LastWriteTime.Ticks, minimumDateTime.Value.Ticks, destinationCollection.ToArray()));
|
||||
else
|
||||
results.Add(new(item, item.ImageFileHolder.LastWriteTime.Value.Ticks, minimumDateTime.Value.Ticks, destinationCollection.ToArray()));
|
||||
}
|
||||
return results;
|
||||
}
|
||||
@ -419,11 +420,12 @@ public class DateGroup
|
||||
{
|
||||
if (_Log is null)
|
||||
throw new NullReferenceException(nameof(_Log));
|
||||
string checkDirectory;
|
||||
bool hasDuplicate;
|
||||
string fullFileName;
|
||||
string directoryName;
|
||||
WindowsShortcut windowsShortcut;
|
||||
string duplicate = "-Duplicate";
|
||||
string duplicate = "-Duplicates";
|
||||
List<string> filesDistinct = new();
|
||||
List<string> filesDuplicate = new();
|
||||
List<string> directoriesDistinct = new();
|
||||
@ -440,12 +442,17 @@ public class DateGroup
|
||||
directoriesDistinct.Add(directoryName);
|
||||
if (!Directory.Exists(directoryName))
|
||||
_ = Directory.CreateDirectory(directoryName);
|
||||
if (!Directory.Exists(string.Concat(directoryName, duplicate, " I")))
|
||||
_ = Directory.CreateDirectory(string.Concat(directoryName, duplicate, " I"));
|
||||
if (!Directory.Exists(string.Concat(directoryName, duplicate, " II")))
|
||||
_ = Directory.CreateDirectory(string.Concat(directoryName, duplicate, " II"));
|
||||
checkDirectory = Path.Combine(string.Concat(directoryName, duplicate), "I");
|
||||
if (!Directory.Exists(checkDirectory))
|
||||
_ = Directory.CreateDirectory(checkDirectory);
|
||||
for (int i = 0; i < 200 - checkDirectory.Length; i++)
|
||||
{
|
||||
checkDirectory = string.Concat(checkDirectory, "I");
|
||||
if (!Directory.Exists(checkDirectory))
|
||||
_ = Directory.CreateDirectory(checkDirectory);
|
||||
}
|
||||
}
|
||||
_Log.Information("Ready to move files?");
|
||||
_Log.Information($"Ready to move {fileMoveCollectionAll.Length} file(s)?");
|
||||
for (int y = 0; y < int.MaxValue; y++)
|
||||
{
|
||||
_Log.Information("Press \"Y\" key to move file(s) or close console to not move files");
|
||||
@ -460,16 +467,16 @@ public class DateGroup
|
||||
hasDuplicate = filesDuplicate.Contains(fullFileName);
|
||||
if (hasDuplicate)
|
||||
{
|
||||
destination[1] = string.Concat(destination[1], duplicate, " I");
|
||||
destination[0] = Path.Combine(string.Concat(destination[0], duplicate), "I");
|
||||
fullFileName = Path.Combine(destination);
|
||||
}
|
||||
for (int i = 0; i < 256 - destination[1].Length; i++)
|
||||
for (int i = 0; i < 200 - destination[0].Length; i++)
|
||||
{
|
||||
if (!File.Exists(fullFileName))
|
||||
break;
|
||||
else
|
||||
{
|
||||
destination[1] = string.Concat(destination[1], "I");
|
||||
destination[0] = string.Concat(destination[0], "I");
|
||||
fullFileName = Path.Combine(destination);
|
||||
if (File.Exists(fullFileName))
|
||||
continue;
|
||||
|
Reference in New Issue
Block a user