Skip to content

Instantly share code, notes, and snippets.

@petesql
Created January 24, 2019 20:10
Show Gist options
  • Save petesql/b09b9eb406ad6ebfe0c8feb9994f9943 to your computer and use it in GitHub Desktop.
Save petesql/b09b9eb406ad6ebfe0c8feb9994f9943 to your computer and use it in GitHub Desktop.
count_rows_within_csv_files
# Count rows within CSV files, in a specified directory.
Get-ChildItem "C:\myfolder\" -re -in "*.csv" |
Foreach-Object {
$fileStats = Get-Content $_.FullName | Measure-Object -line
$linesInFile = $fileStats.Lines -1
Write-Host "$_,$linesInFile"
}
@petesql
Copy link
Author

petesql commented Nov 2, 2022

Blog Post containing an example of using this script >
Count Rows within CSV Files using PowerShell
https://peter-whyte.com/count-rows-within-csv-files-using-powershell/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment