Skip to content

Instantly share code, notes, and snippets.

@stofte
Created April 28, 2016 12:48
Show Gist options
  • Save stofte/77d808420c5bcfbfc5e79f0531f37504 to your computer and use it in GitHub Desktop.
Save stofte/77d808420c5bcfbfc5e79f0531f37504 to your computer and use it in GitHub Desktop.
$counts = @{".cs"=0;".js"=0;".xml"=0;".config"=0}
$excludeList = @()
Get-ChildItem -Recurse | % {
$pathParts = $_.FullName.substring($pwd.path.Length + 1).split("\");
if ( ! ($excludeList | where { $pathParts -like $_ } ) ) { $_ }
} |
where { $_.FullName -ne $_.Directory -and $_.Extension -ne $null } |
foreach-object -process {
try {
if ($counts.ContainsKey($_.Extension)) {
[int]$curr = [int]$counts.Get_Item($_.Extension);
$add = [int]::Parse(([regex]'^\W*(\d+)').match((C:\bin\wc.exe -l $_.FullName)).groups[1].value);
[console]::writeline("{0}:{1}+{2}", $_.FullName, $curr, $add)
$counts.Set_Item($_.Extension, $curr + $add)
}
} catch {
Write-Error $_.Exception.Message
}
}
$counts | format-list
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment