Rename
editorconfig
This commit is contained in:
@ -18,7 +18,7 @@ public class DeleteByDistinct
|
||||
if (console is null)
|
||||
{ }
|
||||
long ticks = DateTime.Now.Ticks;
|
||||
Dictionary<string, List<string>> keyValuePairs = new();
|
||||
Dictionary<string, List<string>> keyValuePairs = [];
|
||||
Configuration configuration = Property.Models.Binder.Configuration.Get(isEnvironment, configurationRoot);
|
||||
ProgressBarOptions options = new() { ProgressCharacter = '─', ProgressBarOnBottom = true, DisableBottomPercentage = true };
|
||||
logger?.LogInformation(configuration.RootDirectory);
|
||||
@ -42,11 +42,11 @@ public class DeleteByDistinct
|
||||
List<string>? fileNames;
|
||||
ProgressBar progressBar;
|
||||
ConsoleKey? consoleKey = null;
|
||||
List<string> deletedFiles = new();
|
||||
List<string> deletedFiles = [];
|
||||
int pad = ticks.ToString().Length + 1;
|
||||
List<string> deletedDirectories = new();
|
||||
Dictionary<long, List<string>> longToCollectionB = new();
|
||||
List<(string Source, string Destination)> renameFiles = new();
|
||||
List<string> deletedDirectories = [];
|
||||
Dictionary<long, List<string>> longToCollectionB = [];
|
||||
List<(string Source, string Destination)> renameFiles = [];
|
||||
logger?.LogInformation($"Gathering {appSettings.SearchPattern} files from <{directory}>");
|
||||
(string directory, string[] files)[] leftCollection = Shared.Models.Stateless.Methods.IFileHolder.GetFiles(directory, appSettings.SearchPattern).ToArray();
|
||||
totalSeconds = (int)Math.Floor(new TimeSpan(DateTime.Now.Ticks - ticks).TotalSeconds);
|
||||
@ -86,12 +86,12 @@ public class DeleteByDistinct
|
||||
throw new Exception();
|
||||
if (!keyValuePairs.TryGetValue(check, out fileNames))
|
||||
{
|
||||
keyValuePairs.Add(check, new());
|
||||
keyValuePairs.Add(check, []);
|
||||
if (!keyValuePairs.TryGetValue(check, out fileNames))
|
||||
throw new Exception();
|
||||
}
|
||||
checkName = fileInfo.Name.ToLower().Replace(".jpeg", ".jpg");
|
||||
if (!fileNames.Any())
|
||||
if (fileNames.Count == 0)
|
||||
fileNames.Add(checkName);
|
||||
else if (!logOnly && appSettings.RenameToMatch && fileNames.Count == 1 && fileInfo.DirectoryName is not null && fileInfo.Name != fileNames.First())
|
||||
renameFiles.Add((fileInfo.FullName, Path.Combine(fileInfo.DirectoryName, fileNames.First())));
|
||||
@ -108,7 +108,7 @@ public class DeleteByDistinct
|
||||
logFile = $"{ticks}-{variable}-Files-A.lsv";
|
||||
if (!logOnly)
|
||||
File.WriteAllLines(Path.Combine(directory, logFile), deletedFiles);
|
||||
if (deletedFiles.Any() && !logOnly)
|
||||
if (deletedFiles.Count != 0 && !logOnly)
|
||||
{
|
||||
logger?.LogInformation($"Ready to delete {deletedFiles.Count} from {variable} {appSettings.SearchPattern} file(s)? See <{logFile}>");
|
||||
for (int y = 0; y < int.MaxValue; y++)
|
||||
@ -142,9 +142,9 @@ public class DeleteByDistinct
|
||||
for (int i = 1; i < 5; i++)
|
||||
{
|
||||
progressBar.Tick();
|
||||
List<string> collection = new();
|
||||
List<string> collection = [];
|
||||
Shared.Models.Stateless.Methods.IPath.DeleteEmptyDirectories(directory, collection);
|
||||
if (!collection.Any())
|
||||
if (collection.Count == 0)
|
||||
break;
|
||||
deletedDirectories.AddRange(collection);
|
||||
}
|
||||
@ -154,7 +154,7 @@ public class DeleteByDistinct
|
||||
File.WriteAllLines(Path.Combine(directory, logFile), deletedDirectories.Distinct());
|
||||
}
|
||||
}
|
||||
if (!logOnly && renameFiles.Any())
|
||||
if (!logOnly && renameFiles.Count != 0)
|
||||
{
|
||||
logFile = $"{ticks}-{variable}-Files-B.lsv";
|
||||
File.WriteAllLines(Path.Combine(directory, logFile), renameFiles.Select(l => l.Source));
|
||||
|
@ -60,7 +60,7 @@ public class Program
|
||||
if (args is not null)
|
||||
Secondary(logger, args.ToList());
|
||||
else
|
||||
Secondary(logger, new List<string>());
|
||||
Secondary(logger, []);
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user