diff --git a/.vscode/tasks.json b/.vscode/tasks.json
index 01b9f0c..d9d7b4d 100644
--- a/.vscode/tasks.json
+++ b/.vscode/tasks.json
@@ -121,6 +121,12 @@
"command": "& L:/DevOps/Mesa_FI/File-Folder-Helper/bin/Release/net7.0/win-x64/publish/File-Folder-Helper.exe s S 'L:/BaGet/packages'",
"problemMatcher": []
},
+ {
+ "label": "File-Folder-Helper AOT s V Helpers",
+ "type": "shell",
+ "command": "& L:/DevOps/Mesa_FI/File-Folder-Helper/bin/Release/net7.0/win-x64/publish/File-Folder-Helper.exe s V Helpers",
+ "problemMatcher": []
+ },
{
"label": "Kanbn Console",
"type": "npm",
diff --git a/File-Folder-Helper.csproj b/File-Folder-Helper.csproj
index bd3b9d5..e56bde0 100644
--- a/File-Folder-Helper.csproj
+++ b/File-Folder-Helper.csproj
@@ -9,7 +9,7 @@
eb9e8f58-fcb5-45bb-9d4d-54f064c485b1
-
+
diff --git a/Helpers/HelperGenealogicalDataCommunication.cs b/Helpers/HelperGenealogicalDataCommunication.cs
index 49f1093..751d158 100644
--- a/Helpers/HelperGenealogicalDataCommunication.cs
+++ b/Helpers/HelperGenealogicalDataCommunication.cs
@@ -63,6 +63,9 @@ internal static partial class HelperGenealogicalDataCommunication
private static string? GetFaceBookId(Person person) =>
person.Birth?.Continue.Where(l => l.StartsWith("https://www.facebook.com/profile.php?id=")).Select(l => l[40..].Split('&')[0]).FirstOrDefault();
+ private static string GetKey(Family family) =>
+ $"{family.Id}-{family.Index}".Trim('-');
+
private static ReadOnlyDictionary> Convert(Dictionary> keyValuePairs)
{
Dictionary> results = new();
@@ -110,29 +113,24 @@ internal static partial class HelperGenealogicalDataCommunication
return new(results);
}
- private static string GetKey(Family family) =>
- $"{family.Id}-{family.Index}".Trim('-');
-
- private static ReadOnlyCollection GetHeaderLines(string startsWith, string[] sourceLines)
+ private static ReadOnlyCollection GetDistinctSortedKeys(List familyCollection, char personTitleFilter)
{
- List results = new();
- for (int i = 0; i < sourceLines.Length; i++)
+ string[] results;
+ string key;
+ List<(string? Index, string Key)> collection = new();
+ foreach (Family family in familyCollection)
{
- if (sourceLines[i].StartsWith(startsWith))
- break;
- results.Add(sourceLines[i]);
+ if (family.Id is null)
+ continue;
+ if (string.IsNullOrEmpty(family.Title) || family.Title[0] != personTitleFilter)
+ continue;
+ key = GetKey(family);
+ collection.Add((family.Index, key));
}
+ results = (from l in collection orderby l.Key, l.Index?.Length descending select l.Key).Distinct().ToArray();
return new(results);
}
- private static long? GetId(string line)
- {
- long? result;
- string[] segments = line.Split('@');
- result = segments[1].Length < 2 || !long.TryParse(segments[1][1..], out long idValue) ? null : idValue;
- return result;
- }
-
private static Dictionary>> Convert(ReadOnlyCollection distinctSortedKKeys)
{
Dictionary>> results = new();
@@ -154,6 +152,26 @@ internal static partial class HelperGenealogicalDataCommunication
return results;
}
+ private static ReadOnlyCollection GetHeaderLines(string startsWith, string[] sourceLines)
+ {
+ List results = new();
+ for (int i = 0; i < sourceLines.Length; i++)
+ {
+ if (sourceLines[i].StartsWith(startsWith))
+ break;
+ results.Add(sourceLines[i]);
+ }
+ return new(results);
+ }
+
+ private static long? GetId(string line)
+ {
+ long? result;
+ string[] segments = line.Split('@');
+ result = segments[1].Length < 2 || !long.TryParse(segments[1][1..], out long idValue) ? null : idValue;
+ return result;
+ }
+
private static Dictionary> GetTxtFileCollection(Input input)
{
Dictionary> results = new();
@@ -455,21 +473,30 @@ internal static partial class HelperGenealogicalDataCommunication
return new(results.OrderBy(l => l.FamilyIndex).ToArray());
}
- private static ReadOnlyCollection GetDistinctSortedKeys(List familyCollection, char personTitleFilter)
+ private static ReadOnlyDictionary>> GetKeyValuePairs(List familyCollection, char personTitleFilter)
{
- string[] results;
+ Dictionary>> results;
+ Dictionary>> keyValuePairs;
+ string id;
string key;
- List<(string? Index, string Key)> collection = new();
+ ReadOnlyCollection collection;
+ List>? objectCollection;
+ ReadOnlyCollection distinctSortedKeys = GetDistinctSortedKeys(familyCollection, personTitleFilter);
+ keyValuePairs = Convert(distinctSortedKeys);
foreach (Family family in familyCollection)
{
if (family.Id is null)
continue;
if (string.IsNullOrEmpty(family.Title) || family.Title[0] != personTitleFilter)
continue;
+ id = family.Person.Id.ToString();
key = GetKey(family);
- collection.Add((family.Index, key));
+ if (!keyValuePairs.TryGetValue(key, out objectCollection))
+ throw new NotSupportedException();
+ collection = GetObjectCollection(family.Person);
+ objectCollection.Add(collection);
}
- results = (from l in collection orderby l.Key, l.Index?.Length descending select l.Key).Distinct().ToArray();
+ results = Convert(keyValuePairs);
return new(results);
}
@@ -799,33 +826,6 @@ internal static partial class HelperGenealogicalDataCommunication
return results;
}
- private static ReadOnlyDictionary>> GetKeyValuePairs(List familyCollection, char personTitleFilter)
- {
- Dictionary>> results;
- Dictionary>> keyValuePairs;
- string id;
- string key;
- ReadOnlyCollection collection;
- List>? objectCollection;
- ReadOnlyCollection distinctSortedKeys = GetDistinctSortedKeys(familyCollection, personTitleFilter);
- keyValuePairs = Convert(distinctSortedKeys);
- foreach (Family family in familyCollection)
- {
- if (family.Id is null)
- continue;
- if (string.IsNullOrEmpty(family.Title) || family.Title[0] != personTitleFilter)
- continue;
- id = family.Person.Id.ToString();
- key = GetKey(family);
- if (!keyValuePairs.TryGetValue(key, out objectCollection))
- throw new NotSupportedException();
- collection = GetObjectCollection(family.Person);
- objectCollection.Add(collection);
- }
- results = Convert(keyValuePairs);
- return new(results);
- }
-
private static void WriteJsonFiles(AppSettings appSettings, Input input, GenealogicalDataCommunicationCollections genealogicalDataCommunicationCollections, ReadOnlyDictionary people, List familyCollection)
{
string json;
diff --git a/Helpers/HelperKanbanMetadata.cs b/Helpers/HelperKanbanMetadata.cs
index 237e264..e764de8 100644
--- a/Helpers/HelperKanbanMetadata.cs
+++ b/Helpers/HelperKanbanMetadata.cs
@@ -14,6 +14,18 @@ internal static partial class HelperKanbanMetadata
[GeneratedRegex("[\\s!?.,@:;|\\\\/\"'`£$%\\^&*{}[\\]()<>~#+\\-=_¬]+")]
private static partial Regex InvalidCharacter();
+ private static string GetParamCase(string value)
+ {
+ string result;
+ StringBuilder stringBuilder = new(value);
+ Match[] matches = UpperCase().Matches(value).ToArray();
+ for (int i = matches.Length - 1; i > -1; i--)
+ _ = stringBuilder.Insert(matches[i].Index, '-');
+ string[] segments = InvalidCharacter().Split(stringBuilder.ToString().ToLower());
+ result = string.Join('-', segments).Trim('-');
+ return result;
+ }
+
private static void TestParamCases()
{
if (GetParamCase("PascalCase") != "pascal-case")
@@ -84,18 +96,6 @@ internal static partial class HelperKanbanMetadata
return results;
}
- private static string GetParamCase(string value)
- {
- string result;
- StringBuilder stringBuilder = new(value);
- Match[] matches = UpperCase().Matches(value).ToArray();
- for (int i = matches.Length - 1; i > -1; i--)
- _ = stringBuilder.Insert(matches[i].Index, '-');
- string[] segments = InvalidCharacter().Split(stringBuilder.ToString().ToLower());
- result = string.Join('-', segments).Trim('-');
- return result;
- }
-
internal static void SetMetadata(ILogger log, AppSettings appSettings, string sourceDirectory)
{
bool? match;
diff --git a/Helpers/HelperMarkdown.cs b/Helpers/HelperMarkdown.cs
index 89e5bb8..cc25abe 100644
--- a/Helpers/HelperMarkdown.cs
+++ b/Helpers/HelperMarkdown.cs
@@ -1155,12 +1155,11 @@ internal static partial class HelperMarkdown
relativeToCollection = GetRelativeToCollection(appSettings, input);
logger.LogInformation("{updated} Markdown file(s) were updated", updated);
}
- if (!string.IsNullOrEmpty(input.StartAt))
+ if (!string.IsNullOrEmpty(input.StartAt) && !string.IsNullOrEmpty(input.Destination))
{
relativeToCollection = GetRelativeToCollection(appSettings, input, force: true);
List markdownFileAndLinesCollection = GetRecursiveLines(appSettings, input, logger, relativeToCollection);
- if (!string.IsNullOrEmpty(input.Destination))
- Write(input, markdownFileAndLinesCollection);
+ Write(input, markdownFileAndLinesCollection);
}
string directory = Path.Combine(Environment.CurrentDirectory, ".vscode");
if (!Directory.Exists(directory))
diff --git a/Helpers/HelperSaveOrCopyContents.cs b/Helpers/HelperSaveOrCopyContents.cs
index 280429b..4bf7dd1 100644
--- a/Helpers/HelperSaveOrCopyContents.cs
+++ b/Helpers/HelperSaveOrCopyContents.cs
@@ -223,4 +223,20 @@ internal static class HelperSaveOrCopyContents
}
}
+ internal static void IgnoreCaseAndRenameFilesToLowercase(ILogger log, string argsZero)
+ {
+ string fileName;
+ int filesRenamed = 0;
+ string[] files = Directory.GetFiles(argsZero, "*", SearchOption.TopDirectoryOnly);
+ foreach (string file in files)
+ {
+ fileName = Path.GetFileName(file);
+ if (fileName == fileName.ToLower())
+ continue;
+ File.Move(file, file.ToLower());
+ filesRenamed++;
+ }
+ log.LogInformation("{filesRenamed}(s) renamed", filesRenamed);
+ }
+
}
\ No newline at end of file
diff --git a/Worker.cs b/Worker.cs
index 9d11cdd..454e36f 100644
--- a/Worker.cs
+++ b/Worker.cs
@@ -34,6 +34,7 @@ public class Worker : BackgroundService
ConsoleKey.F,
ConsoleKey.G,
ConsoleKey.H,
+ ConsoleKey.I,
ConsoleKey.J,
ConsoleKey.K,
ConsoleKey.L,
@@ -95,20 +96,20 @@ public class Worker : BackgroundService
_Logger.LogInformation("F) Clipboard (All Directories and File Name Without Extension),");
_Logger.LogInformation("G) Genealogical Data Communication");
_Logger.LogInformation("H) Hardcoded file search and sort,");
- // I
- _Logger.LogInformation("J) Set Date from Json Entry");
- _Logger.LogInformation("K) Kanban support");
+ _Logger.LogInformation("I) Ignore case and rename files to lowercase,");
+ _Logger.LogInformation("J) Set Date from Json Entry,");
+ _Logger.LogInformation("K) Kanban support,");
_Logger.LogInformation("L) Log Merge (APC Log [0-9(8)]_*.log),");
_Logger.LogInformation("N) Create Note Files,");
_Logger.LogInformation("M) Markdown Wiki Link Verification,");
// O
// P
// Q
- _Logger.LogInformation("R) Rename to old, copy, delete old");
- _Logger.LogInformation("S) Set Date from Zip Entry");
- _Logger.LogInformation("T) Too long rename");
- _Logger.LogInformation("U) Links for Hugo");
- _Logger.LogInformation("V) VSCode Hope Sort");
+ _Logger.LogInformation("R) Rename to old, copy, delete old,");
+ _Logger.LogInformation("S) Set Date from Zip Entry,");
+ _Logger.LogInformation("T) Too long rename,");
+ _Logger.LogInformation("U) Links for Hugo,");
+ _Logger.LogInformation("V) VSCode Hope Sort,");
// W
// X
// Y
@@ -132,6 +133,9 @@ public class Worker : BackgroundService
case ConsoleKey.H:
Helpers.HelperHardcodedFileSearchAndSort.HardcodedFileSearchAndSort(_Logger, _Args[0]);
break;
+ case ConsoleKey.I:
+ Helpers.HelperSaveOrCopyContents.IgnoreCaseAndRenameFilesToLowercase(_Logger, _Args[0]);
+ break;
case ConsoleKey.J:
Helpers.HelperPackageFilesByDate.SetDateFromJsonEntry(_Logger, _Args[0]);
break;