Skip to content

Instantly share code, notes, and snippets.

@dylanmartin
Created September 4, 2024 18:35
Show Gist options
  • Save dylanmartin/50a79d4ad44ac932a5958480d541e578 to your computer and use it in GitHub Desktop.
Save dylanmartin/50a79d4ad44ac932a5958480d541e578 to your computer and use it in GitHub Desktop.
fix headers
# Get all .txt files in the current directory
Get-ChildItem -Filter *.txt | ForEach-Object {
# Read the file content
$filePath = $_.FullName
$content = Get-Content $filePath
# Split the first line by tabs and replace the first and second columns' headers
$header = $content[0] -split "`t"
$header[0] = "Measure:volume"
$header[1] = "subject_000"
# Join the modified header back with tabs
$content[0] = $header -join "`t"
# Write the updated content back to the file
$content | Set-Content $filePath
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment