Last active
February 4, 2021 07:07
-
-
Save mattia72/9f46777830ac8d0c1351e2db82d316c6 to your computer and use it in GitHub Desktop.
Adds header for every file in a list with powershell
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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