-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcount.ps1
More file actions
35 lines (29 loc) · 1.28 KB
/
count.ps1
File metadata and controls
35 lines (29 loc) · 1.28 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
# Set the path to the directory you want to search
$directory = "."
# Set a list of directory names to exclude
$excludedDirectories = @("nlohmann", "stb", "DirectX", "pix", "Intel", "FidelityFX", "ThirdParty", ".*", "models", "textures", "out", "Aftermath", "NVSL", "vcpkg_installed", "tree-sitter-hlsl")
# File extensions to include in the search (e.g., .txt, .cpp, .h)
$includeExtensions = @("*.txt", "*.cpp", "*.h")
# Use Get-ChildItem to get all matching files in the directory recursively
$files = Get-ChildItem -Path $directory -Recurse -Include $includeExtensions |
Where-Object {
# Check if any part of the directory path contains an excluded directory name
$exclude = $false
foreach ($excluded in $excludedDirectories) {
if ($_.FullName -like "*\$excluded\*") {
$exclude = $true
break
}
}
return -not $exclude
}
# Initialize a counter for the total number of lines
$totalLines = 0
# Loop through each file, print the filename, and count the lines
foreach ($file in $files) {
Write-Host "Processing file: $($file.FullName)"
$lineCount = (Get-Content $file.FullName).Count
$totalLines += $lineCount
}
# Output the total number of lines
Write-Host "Total number of lines: $totalLines"