$folderPath = Read-Host "Enter the folder path"
function mainMenu {
while($prompt -ne ''){$totaLines = 0
$n = 0
Get-ChildItem -Path $folderPath -Filter *.txt -Recurse | ForEach-Object {
$fileLines = (Get-Content $_.FullName | Measure-Object -Line).Lines
Write-Host "$($_.Name): $fileLines lines" -ForegroundColor "Yellow"
$n+=1
$totaLines+=$fileLines
}write-Host$prompt = Read-Host "Should the first row be excluded as the header row: Y or N (Leave blank quit )"
if ($prompt -eq "Y"){
$totaLines=$totaLines - $n
Write-Host "Total lines :$totaLines lines" -ForegroundColor "Green"
}
if ($prompt -eq "N"){
Write-Host "Total lines :$totaLines lines" -ForegroundColor "Green"
}
}
}
mainMenu