GetToDoCollection
This commit is contained in:
parent
9dd218a5f2
commit
375447ce97
@ -1,12 +1,12 @@
|
||||
{
|
||||
"CompareRootDirectory": "D:/7) Question/- - - Images - 2023-01-12/fa60aa45ebb55fe3ee0ce4da8a64e40611e7d5ce",
|
||||
"CompareRootDirectory": "D:/7) Question/- - - Images - 2023-01-12/d02c8791fa0b130c0bce2d39ee684e50f7ee7a97-Not-Copy-Copy",
|
||||
"Logging": {
|
||||
"LogLevel": {
|
||||
"Log4netProvider": "Debug"
|
||||
}
|
||||
},
|
||||
"MaxDegreeOfParallelism": 6,
|
||||
"RecycleOption": true,
|
||||
"RecycleOption": false,
|
||||
"SearchPattern": "*.*",
|
||||
"Serilog": {
|
||||
"MinimumLevel": "Debug"
|
||||
@ -18,7 +18,9 @@
|
||||
"xxxRootDirectory": "D:/1) Images A/Images-45f4401",
|
||||
"xxxxRootDirectory": "E:/3) Videos A/Device Videos 2_0_0_3 - Current",
|
||||
"xxxxxRootDirectory": "E:/4) Videos B/Device Videos 2_0_0_3 - Current - Ignore",
|
||||
"RootDirectory": "C:/1) Images A/Images-45f4401",
|
||||
"xxxxxxRootDirectory": "C:/1) Images A/Images-45f4401",
|
||||
"xxxxxxxRootDirectory": "C:/2) Images B/Not-Copy-Copy-45f4401",
|
||||
"xxxxxxxxRootDirectory": "D:/7) Question/- - - Images - 2023-01-12/fa60aa45ebb55fe3ee0ce4da8a64e40611e7d5ce",
|
||||
"VerifyToSeason": []
|
||||
}
|
||||
}
|
||||
|
@ -92,7 +92,7 @@ public class Rename
|
||||
}
|
||||
}
|
||||
|
||||
private List<(FileHolder, string)> GetRenameCollection(ProgressBar progressBar, string[] files)
|
||||
private List<(FileHolder, string)> GetToDoCollection(ProgressBar progressBar, string[] files)
|
||||
{
|
||||
List<(FileHolder, string)> results = new();
|
||||
int? id;
|
||||
@ -271,22 +271,30 @@ public class Rename
|
||||
}
|
||||
}
|
||||
|
||||
private void CopyInstead(List<(FileHolder, string)> renameCollection)
|
||||
private void CopyInstead(List<(FileHolder, string)> toDoCollection)
|
||||
{
|
||||
string copyTo;
|
||||
string? directory;
|
||||
List<string> distinctDirectories = new();
|
||||
foreach ((FileHolder fileHolder, string to) in renameCollection)
|
||||
List<(FileHolder, string)> copyCollection = new();
|
||||
foreach ((FileHolder fileHolder, string to) in toDoCollection)
|
||||
{
|
||||
directory = Path.GetDirectoryName($"{_AppSettings.CopyTo}{to[1..]}");
|
||||
copyTo = $"{_AppSettings.CopyTo}{to[1..]}";
|
||||
directory = Path.GetDirectoryName(copyTo);
|
||||
if (directory is null)
|
||||
continue;
|
||||
copyCollection.Add(new(fileHolder, copyTo));
|
||||
if (distinctDirectories.Contains(directory))
|
||||
continue;
|
||||
distinctDirectories.Add(directory);
|
||||
}
|
||||
CreateDirectories(distinctDirectories);
|
||||
foreach ((FileHolder fileHolder, string to) in renameCollection)
|
||||
File.Copy(fileHolder.FullName, $"{_AppSettings.CopyTo}{to[1..]}");
|
||||
foreach ((FileHolder fileHolder, string to) in copyCollection)
|
||||
{
|
||||
if (File.Exists(to))
|
||||
continue;
|
||||
File.Copy(fileHolder.FullName, to);
|
||||
}
|
||||
}
|
||||
|
||||
private List<string> RenameFilesInDirectories(ProgressBarOptions options, MatchNginx[] matchNginxCollection)
|
||||
@ -297,7 +305,7 @@ public class Rename
|
||||
int distinctCount;
|
||||
ProgressBar progressBar;
|
||||
List<string> distinctCollection = new();
|
||||
List<(FileHolder, string)> renameCollection;
|
||||
List<(FileHolder, string)> toDoCollection;
|
||||
List<string> allFiles = GetAllFiles(matchNginxCollection);
|
||||
for (int i = 1; i < 3; i++)
|
||||
{
|
||||
@ -307,21 +315,21 @@ public class Rename
|
||||
if (!files.Any())
|
||||
continue;
|
||||
distinctCollection.Clear();
|
||||
renameCollection = GetRenameCollection(progressBar, files);
|
||||
foreach ((FileHolder fileHolder, string to) in renameCollection)
|
||||
toDoCollection = GetToDoCollection(progressBar, files);
|
||||
foreach ((FileHolder fileHolder, string to) in toDoCollection)
|
||||
{
|
||||
if (distinctCollection.Contains(to))
|
||||
continue;
|
||||
distinctCollection.Add(to);
|
||||
}
|
||||
distinctCount = distinctCollection.Count;
|
||||
if (renameCollection.Count != distinctCount)
|
||||
if (toDoCollection.Count != distinctCount)
|
||||
continue;
|
||||
if (!string.IsNullOrEmpty(_AppSettings.CopyTo))
|
||||
CopyInstead(renameCollection);
|
||||
CopyInstead(toDoCollection);
|
||||
else
|
||||
{
|
||||
foreach ((FileHolder fileHolder, string to) in renameCollection)
|
||||
foreach ((FileHolder fileHolder, string to) in toDoCollection)
|
||||
{
|
||||
results.Add(fileHolder.NameWithoutExtension);
|
||||
if (File.Exists(to))
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"ComparePathsFile": "C:/Users/mikep/AppData/Local/PharesApps/Drag-Drop-Explorer/2023_03/638095753937985087.json",
|
||||
"CopyTo": "C",
|
||||
"ComparePathsFile": "C:/Users/mikep/AppData/Local/PharesApps/Drag-Drop-Explorer/2023_03/638095825580115652.json",
|
||||
"CopyTo": "",
|
||||
"Logging": {
|
||||
"LogLevel": {
|
||||
"Log4netProvider": "Debug"
|
||||
|
@ -1,6 +1,7 @@
|
||||
{
|
||||
"ComparePathsFile": "",
|
||||
"Company": "Mike Phares",
|
||||
"CopyTo": "",
|
||||
"Linux": {},
|
||||
"Logging": {
|
||||
"LogLevel": {
|
||||
|
Loading…
x
Reference in New Issue
Block a user