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