title: Line Count ForEach-Object on multiple files
body: <p>I'm trying to figure out how to incorporate a line count that gets added to each file for a loop.  The count needs to be put into the footer of each file as it checks it.  Another concern is that the count needs to include the addition of the header and footer lines (i.e. 8 lines + 1 header + 1 footer = 10).  My code I'm using is below and I know that the code to count the lines is <code>Get-Content $mypath | Measure-Object -Line | {$linecount = $_.Count}</code> but I dont know how to properly incorporate it.  Any suggestions?</p>
  
  <pre><code>Get-ChildItem $destinationfolderpath -REcurse -Filter *.txt | ForEach-Object -Begin { $seq = 0 } -Process {
          $seq++ 
          $seq1 = "{0:D4}" -f $seq; $header="File Sequence Number $seq1"
          $footer="File Sequence Number $seq1 and Line Count $looplinecount"
          $header + "`n" + (Get-Content $_.FullName | Out-String) + $footer | Set-Content -Path $_.FullName
  }
  </code></pre>