MoveTo => CopyTo
This commit is contained in:
parent
1712de2952
commit
91f32138a1
@ -32,7 +32,7 @@ public class CopyDistinct
|
||||
string[] directories = new string[] { "()" };
|
||||
ILogger? log = Log.ForContext<CopyDistinct>();
|
||||
Property.Models.Configuration propertyConfiguration = Property.Models.Binder.Configuration.Get(isEnvironment, configurationRoot);
|
||||
_JsonGroups = Shared.Models.Stateless.Methods.IPath.GetKeyValuePairs(propertyConfiguration.ResultAllInOne, appSettings.MoveTo, directories, appSettings.MaxValue);
|
||||
_JsonGroups = Shared.Models.Stateless.Methods.IPath.GetKeyValuePairs(propertyConfiguration.ResultAllInOne, appSettings.CopyTo, directories, appSettings.MaxValue);
|
||||
Configuration configuration = Models.Binder.Configuration.Get(isEnvironment, configurationRoot, propertyConfiguration);
|
||||
_PropertyConfiguration = propertyConfiguration;
|
||||
_Configuration = configuration;
|
||||
@ -104,7 +104,7 @@ public class CopyDistinct
|
||||
if (isIgnoreExtension || !isValidImageFormatExtension)
|
||||
continue;
|
||||
nameWithoutExtensionIsIdFormat = Shared.Models.Stateless.Methods.IProperty.NameWithoutExtensionIsIdFormat(fileHolder);
|
||||
if (nameWithoutExtensionIsIdFormat)
|
||||
if (!nameWithoutExtensionIsIdFormat)
|
||||
continue;
|
||||
directory = Shared.Models.Stateless.Methods.IDirectory.GetDirectory(fileHolder.NameWithoutExtension, 2);
|
||||
if (!int.TryParse(directory, out directoryIndex))
|
||||
@ -118,21 +118,21 @@ public class CopyDistinct
|
||||
return results;
|
||||
}
|
||||
|
||||
private static List<string> Move(ILogger log, List<(FileHolder, string)> toDoCollection)
|
||||
private static List<string> Copy(ILogger log, List<(FileHolder, string)> toDoCollection)
|
||||
{
|
||||
List<string> results = new();
|
||||
ConsoleKey? consoleKey = null;
|
||||
log.Information($"Ready to Move {toDoCollection.Count} file(s)?");
|
||||
log.Information($"Ready to Copy {toDoCollection.Count} file(s)?");
|
||||
for (int y = 0; y < int.MaxValue; y++)
|
||||
{
|
||||
log.Information("Press \"Y\" key to move file(s), \"N\" key to log file(s) or close console to not move files");
|
||||
log.Information("Press \"Y\" key to copy file(s), \"N\" key to log file(s) or close console to not copy files");
|
||||
consoleKey = System.Console.ReadKey().Key;
|
||||
if (consoleKey is ConsoleKey.Y or ConsoleKey.N)
|
||||
break;
|
||||
}
|
||||
log.Information(". . .");
|
||||
if (consoleKey is null || consoleKey.Value != ConsoleKey.Y)
|
||||
log.Information("Nothing moved!");
|
||||
log.Information("Nothing copied!");
|
||||
else
|
||||
{
|
||||
foreach ((FileHolder fileHolder, string to) in toDoCollection)
|
||||
@ -142,7 +142,7 @@ public class CopyDistinct
|
||||
{ File.Copy(fileHolder.FullName, to); }
|
||||
catch (Exception) { }
|
||||
}
|
||||
log.Information("Done Moving");
|
||||
log.Information("Done copying");
|
||||
}
|
||||
return results;
|
||||
}
|
||||
@ -158,7 +158,7 @@ public class CopyDistinct
|
||||
ProgressBarOptions options = new() { ProgressCharacter = '─', ProgressBarOnBottom = true, DisableBottomPercentage = true };
|
||||
ProgressBar progressBar = new(allFiles.Count, message, options);
|
||||
List<(FileHolder, string)> toDoCollection = GetToDoCollection(progressBar, allFiles);
|
||||
results.AddRange(Move(log, toDoCollection));
|
||||
results.AddRange(Copy(log, toDoCollection));
|
||||
progressBar.Dispose();
|
||||
return results;
|
||||
}
|
||||
|
@ -7,22 +7,22 @@ public class AppSettings
|
||||
{
|
||||
|
||||
public string Company { init; get; }
|
||||
public string CopyTo { init; get; }
|
||||
public int MaxDegreeOfParallelism { init; get; }
|
||||
public int MaxValue { init; get; }
|
||||
public string MoveTo { init; get; }
|
||||
public string WorkingDirectoryName { init; get; }
|
||||
|
||||
[JsonConstructor]
|
||||
public AppSettings(string company,
|
||||
string copyTo,
|
||||
int maxDegreeOfParallelism,
|
||||
int maxValue,
|
||||
string moveTo,
|
||||
string workingDirectoryName)
|
||||
{
|
||||
Company = company;
|
||||
CopyTo = copyTo;
|
||||
MaxDegreeOfParallelism = maxDegreeOfParallelism;
|
||||
MaxValue = maxValue;
|
||||
MoveTo = moveTo;
|
||||
WorkingDirectoryName = workingDirectoryName;
|
||||
}
|
||||
|
||||
|
@ -11,7 +11,7 @@ public class AppSettings
|
||||
public string Company { get; set; }
|
||||
public int? MaxDegreeOfParallelism { get; set; }
|
||||
public int? MaxValue { get; set; }
|
||||
public string MoveTo { get; set; }
|
||||
public string CopyTo { get; set; }
|
||||
public string WorkingDirectoryName { get; set; }
|
||||
|
||||
#nullable restore
|
||||
@ -31,9 +31,9 @@ public class AppSettings
|
||||
throw new NullReferenceException(nameof(appSettings.MaxValue));
|
||||
result = new(
|
||||
appSettings.Company,
|
||||
appSettings.CopyTo,
|
||||
appSettings.MaxDegreeOfParallelism.Value,
|
||||
appSettings.MaxValue.Value,
|
||||
appSettings.MoveTo,
|
||||
appSettings.WorkingDirectoryName
|
||||
);
|
||||
return result;
|
||||
|
@ -1,6 +1,7 @@
|
||||
{
|
||||
"ComparePathsFile": "",
|
||||
"Company": "Mike Phares",
|
||||
"CopyTo": "",
|
||||
"Linux": {},
|
||||
"Logging": {
|
||||
"LogLevel": {
|
||||
@ -12,7 +13,6 @@
|
||||
},
|
||||
"MaxDegreeOfParallelism": 6,
|
||||
"MaxValue": 12,
|
||||
"MoveTo": "",
|
||||
"Serilog": {
|
||||
"Using": [
|
||||
"Serilog.Sinks.Console",
|
||||
|
Loading…
x
Reference in New Issue
Block a user