Skip to content

Instantly share code, notes, and snippets.

@mattia72
Last active February 4, 2021 07:07
Show Gist options
  • Save mattia72/9f46777830ac8d0c1351e2db82d316c6 to your computer and use it in GitHub Desktop.
Save mattia72/9f46777830ac8d0c1351e2db82d316c6 to your computer and use it in GitHub Desktop.
Adds header for every file in a list with powershell
# Check encoding!
function Add-Header ($file, $firstLine) {
begin {
$content = Get-Content -Encoding Oem -Path $file | Out-String
}
process {
}
end {
"$firstLine`r`n$content" | Set-Content -Encoding Oem -Path $file
}
}
$i=0
Get-Content .\file-list.txt | # Select-Object -first 3 |
ForEach-Object {
Add-Header $_ "// __header text __"
Write-Host $("{0}. ready : {1}" -f $global:i++, $_)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment