Skip to content

Instantly share code, notes, and snippets.

@timgaunt
Created March 7, 2018 07:12
Show Gist options
  • Save timgaunt/b59798b0531d46eb300c1ec1b21c3287 to your computer and use it in GitHub Desktop.
Save timgaunt/b59798b0531d46eb300c1ec1b21c3287 to your computer and use it in GitHub Desktop.
Combine multiple csv or txt files together into one
$getFirstLine = $true;get-childItem "*.csv" | foreach {$filePath = $_;$lines = $lines = Get-Content $filePath;$linesToWrite = switch($getFirstLine) {$true {$lines}; $false {$lines | Select -Skip 1}};$getFirstLine = $false;Add-Content "combined.csv" $linesToWrite;}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment