-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge commit 'bfd31d5ab71108772a27d55d161d127fd15c0766'
- Loading branch information
Showing
3 changed files
with
80 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<OutputType>Exe</OutputType> | ||
<TargetFramework>net8.0</TargetFramework> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
<Nullable>enable</Nullable> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="System.Text.Encoding.CodePages" Version="8.0.0" /> | ||
</ItemGroup> | ||
|
||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; | ||
} |