I'm trying to get the line count of multiple CSV files exported to a CSV file. But it keeps outputting the full path.
This is my Powershell code:
$FullPath = "\\Space\folder1\folder2"
$lineCount = “$FullPath\reports\LineCount.csv”
Get-ChildItem $FullPath *.csv |
Select-Object -Property @(
'FullName'
@{ Name = "LineCount"; Expression = {
@(Get-Content -Path $_.FullName | Select-Object -Skip 1 ).Count
}}
) |
Export-CSV $lineCount -NoTypeInformation
Output right now looks like this:
FullName Count
\\Space\folder1\folder2\ab.csv 24
\\Space\folder1\folder2\bc.csv 30
\\Space\folder1\folder2\cd.csv 10
This is what I want:
FullName Count
ab.csv 24
bc.csv 30
cd.csv 10