Updated count-lines.ps1

This commit is contained in:
Markus Fleschutz 2024-04-18 14:56:44 +02:00
parent 900809ed2d
commit 9ae69818cf
2 changed files with 4 additions and 3 deletions

View File

@ -2,11 +2,11 @@
.SYNOPSIS
Counts the number of lines
.DESCRIPTION
This PowerShell script counts the number of lines in text files (.c/.h/.cpp/.hpp/.java/.ps1/.txt/.md) within a directory tree.
This PowerShell script counts the number of lines in text files (.txt/.md/.c/.h/.cpp/.hpp/.java/.py/.ps1/.bat) within a directory tree.
.PARAMETER pathToDirTree
Specifies the path to the directory tree.
.EXAMPLE
PS> ./count-lines.ps1 C:\cmake
PS> ./count-lines.ps1 C:\Repos\cmake
Found 639921 lines in 11411 text files within 📂cmake in 34 sec.
.LINK
https://github.com/fleschutz/PowerShell
@ -24,7 +24,7 @@ try {
Write-Progress "Counting lines within $pathToDirTree ..."
[int64]$numFiles = [int64]$numLines = 0
Get-ChildItem -Path $pathToDirTree -Include *.c,*.h,*.cpp,*.hpp,*.java,*.ps1,*.txt,*.md -Recurse | ForEach-Object {
Get-ChildItem -Path $pathToDirTree -Include *.txt,*.md,*.c,*.h,*.cpp,*.hpp,*.java,*.py,*.ps1,*.bat -Recurse | ForEach-Object {
$numLines += (Get-Content $_.FullName | Measure-Object -line).Lines
$numFiles++
}

View File

@ -32,6 +32,7 @@ try {
& "$PSScriptRoot/cd-repos.ps1"
& "$PSScriptRoot/fetch-repos.ps1"
" "
& "$PSScriptRoot/play-big-ben.ps1"
& "$PSScriptRoot/write-clock.ps1"
exit 0 # success
} catch {