Skip to content

Instantly share code, notes, and snippets.

@sodejm
Created February 7, 2018 17:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sodejm/0b5fdd1fd00a7e1a0f9cfa1e73b97e9f to your computer and use it in GitHub Desktop.
Save sodejm/0b5fdd1fd00a7e1a0f9cfa1e73b97e9f to your computer and use it in GitHub Desktop.
Basic Powershell script to count lines of code, this probably isn't 100% accurate but works for my basic purposes
# .\countLOC.ps1 -path "C:\code\MyProject" -outputFile "C:\code\loc.csv" -include "*.cs" -exclude "*.designer.cs"
param([string]$path, [string]$outputFile, [string]$include = "*.*", [string]$exclude = "")
Clear-Host
Get-ChildItem -re -in $include -ex $exclude $path |
Foreach-Object { Write-Host "Counting $_.FullName"
$fileStats = Get-Content $_.FullName | Measure-Object -line
$linesInFile = $fileStats.Lines
"$_,$linesInFile" } | Out-File $outputFile -encoding "UTF8"
Write-Host "Complete"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment