Files
2nd/scratch/wiki_final_engine.ps1

57 lines
1.9 KiB
PowerShell

$rawDir = "00_Raw"
$targetBase = "10_Wiki\Topics"
$files = Get-ChildItem -Path $rawDir -Filter "*.md"
foreach ($file in $files) {
$name = $file.Name
$targetFolder = "General Knowledge"
# Pattern Matching Logic
if ($name -match "WARNO|Eugen|Steel|Wargame|10v10|Combined|제병협동|사단|은신|탄도|장갑|소음|가용성|가위바위보") {
$targetFolder = "AI & Games"
}
elseif ($name -match "경제|인플레|수익|가차|결제|통화|싱크|Sinks|IAA|IAP|PBR|가격|지표|수도꼭지|배수구|보상|난이도") {
$targetFolder = "Economics & Algorithms"
}
elseif ($name -match "ndf|parse|WME|War-Yes|Armory|파싱|도구|스크립트|LOD|렌더링|텔레메트리") {
$targetFolder = "Programming & Tools"
}
elseif ($name -match "심리|행동|손실|게이미피케이션|사회|Sociology|대수") {
$targetFolder = "Psychology & Behavior"
}
elseif ($name -match "Pocket|Nexus|Magic|WoW|PLEX|디아블로") {
$targetFolder = "General Knowledge"
}
$dstDir = Join-Path $targetBase $targetFolder
if (-not (Test-Path $dstDir)) { New-Item -ItemType Directory -Path $dstDir -Force | Out-Null }
$dstPath = Join-Path $dstDir $name
# Process Content Safely
try {
$content = Get-Content $file.FullName -Raw -Encoding UTF8
$content = $content -replace '# \[\[(.*?)\]\]', '# $1'
$frontmatter = @"
---
category: $targetFolder
status: Final
converted_at: 2026-04-28
---
"@
$newContent = $frontmatter + $content
[System.IO.File]::WriteAllText($dstPath, $newContent, [System.Text.Encoding]::UTF8)
if (Test-Path $dstPath) {
Remove-Item $file.FullName -Force
Write-Host "Success: $name -> $targetFolder"
}
} catch {
Write-Host "Failed: $name - $($_.Exception.Message)"
}
}