-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlinecounter.ps1
More file actions
46 lines (34 loc) · 1.11 KB
/
linecounter.ps1
File metadata and controls
46 lines (34 loc) · 1.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
$files = 0;
dir . -include *.c,*.cpp,*.h,*.hpp -Recurse | % {
$files++;
}
$i=0;
$k=0;
$words=0;
dir . -include *.c,*.cpp,*.h,*.hpp -Recurse | % {
$count = (gc $_).count;
if ($count) {
if($_.Extension -eq ".cpp"){$cpp = $cpp + [int]$count;}
elseif($_.Extension -eq ".c"){$c = $c + [int]$count;}
elseif($_.Extension -eq ".hpp"){$hpp = $hpp + [int]$count;}
elseif($_.Extension -eq ".h"){$h = $h + [int]$count;}
}
$k = $i/$files*100;
$k = "{0:N0}" -f $k;
$words = ((gc $_) | Measure-Object -word).Words + $words ;
Write-Progress -Activity "Counting lines number:" -status "File $i completed $k%" -percentComplete ($k)
$i++;
}
write-host "`nTotal:";
write-host "______________________________";
write-host "`n Files: $files";
write-host " --------------------------";
write-host "`n .cpp : $cpp";
write-host "`n .c : $c";
write-host "`n .hpp : $hpp";
write-host "`n .h : $h";
write-host "______________________________";
$tot = $cpp+ $c + $hpp + $h;
write-host "`n`nTotal lines: $tot";
write-host "`nTotal words: $words`n`n";
pause