Files
fiction/.agents/skills/write-tianbeng-mingmo-novel/scripts/count_chapter_body.ps1
2026-07-19 22:11:42 +08:00

34 lines
810 B
PowerShell

param(
[Parameter(Mandatory = $true, ValueFromRemainingArguments = $true)]
[string[]] $Path
)
$failed = $false
foreach ($chapterPath in $Path) {
if (-not (Test-Path -LiteralPath $chapterPath -PathType Leaf)) {
Write-Error "File not found: $chapterPath"
$failed = $true
continue
}
$text = Get-Content -LiteralPath $chapterPath -Raw -Encoding UTF8
$body = ($text -split '\*\*\*\*', 2)[0]
$withoutWhitespace = $body -replace '\s', ''
$count = $withoutWhitespace.Length
[pscustomobject]@{
Chapter = [IO.Path]::GetFileNameWithoutExtension($chapterPath)
BodyCharactersWithoutWhitespace = $count
MeetsFiveThousand = ($count -ge 5000)
}
if ($count -lt 5000) {
$failed = $true
}
}
if ($failed) {
exit 1
}