Last active
August 29, 2015 14:07
-
-
Save secretGeek/b6d28bfa1b825c37b170 to your computer and use it in GitHub Desktop.
chapters.ps1 -- gives me a basic table of contents for the book I'm working on, include count of words and remaining todo's in each chapter.
This file contains hidden or 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
$totalWords = 0 | |
$totalTodo = 0; | |
dir *.md | % { | |
$name = $_.Name; | |
$len = $_.length; | |
$todos = (get-content $_ | select-string -pattern "//TODO:").length | |
$subChapters = (get-content $_ | select-string -pattern "^### ").length | |
$words = (get-content $_ | measure-object -word).Words; | |
$totalWords = $totalWords + $words; | |
$totalTodo = $totalTodo + $todos; | |
New-Object PSCustomObject -Property @{ | |
"Name"=$_.Name; | |
"Length"=$_.Length; | |
"Words"=$words | |
"Todos"=$todos | |
"SubChapters"=$subChapters | |
} | |
} | format-table -property Length, Words, Todos, SubChapters, Name | |
write-host "Words: $totalWords, TODO: $totalTodo" -foregroundcolor "white" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment