diff --git a/app/Tool/MVPBlog/MVPBlog.sln b/app/Tool/MVPBlog/MVPBlog.sln new file mode 100644 index 0000000..251be1d --- /dev/null +++ b/app/Tool/MVPBlog/MVPBlog.sln @@ -0,0 +1,22 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.0.31903.59 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MVP博客统计", "MVP博客统计.csproj", "{A56CAE00-C21F-4B30-9D19-7E0493C05A5B}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {A56CAE00-C21F-4B30-9D19-7E0493C05A5B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {A56CAE00-C21F-4B30-9D19-7E0493C05A5B}.Debug|Any CPU.Build.0 = Debug|Any CPU + {A56CAE00-C21F-4B30-9D19-7E0493C05A5B}.Release|Any CPU.ActiveCfg = Release|Any CPU + {A56CAE00-C21F-4B30-9D19-7E0493C05A5B}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection +EndGlobal diff --git "a/app/Tool/MVPBlog/MVP\345\215\232\345\256\242\347\273\237\350\256\241.csproj" "b/app/Tool/MVPBlog/MVP\345\215\232\345\256\242\347\273\237\350\256\241.csproj" new file mode 100644 index 0000000..9e94d6a --- /dev/null +++ "b/app/Tool/MVPBlog/MVP\345\215\232\345\256\242\347\273\237\350\256\241.csproj" @@ -0,0 +1,14 @@ + + + + Exe + net8.0 + enable + enable + + + + + + + diff --git a/app/Tool/MVPBlog/Program.cs b/app/Tool/MVPBlog/Program.cs new file mode 100644 index 0000000..646f194 --- /dev/null +++ b/app/Tool/MVPBlog/Program.cs @@ -0,0 +1,44 @@ +// See https://aka.ms/new-console-template for more information + +using System.Text; +using System.Text.RegularExpressions; + +var blogFolder = @"C:\lindexi\Blog\"; +var output = "Result.csv"; + +Encoding.RegisterProvider(CodePagesEncodingProvider.Instance); + +foreach (var blogFile in Directory.EnumerateFiles(blogFolder, "*.md")) +{ + var fileName = Path.GetFileNameWithoutExtension(blogFile); + + var dateText = ReadDateFromFile(blogFile); + + if (!string.IsNullOrEmpty(dateText)) + { + File.AppendAllText(output, $"\"{fileName}\",{dateText}\r\n", Encoding.GetEncoding("GBK")); + Console.WriteLine($"{fileName} {dateText}"); + } +} + +string? ReadDateFromFile(string blogFile) +{ + using var fileStream = File.OpenRead(blogFile); + using var streamReader = new StreamReader(fileStream); + while (true) + { + var line = streamReader.ReadLine(); + if (line is null) + { + break; + } + + var match = Regex.Match(line, @"<\!\-\- CreateTime\:([\S\s]*) \-\->"); + if (match.Success) + { + return match.Groups[1].Value; + } + } + + return null; +} \ No newline at end of file