Sometime back, I had to check-in a huge automation framework into the TFS repository. I realized that I had not added headers to any cs files. So, I quickly cooked up a powershell script to get this done for me. The code is self explanatory and is as below
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
param($target = "C:\PathtoCodeBase", $companyname = "Whatever", $date = (Get-Date)) | |
$header = "//----------------------------------------------------------------------- // | |
//<copyright file=""{0}"" company=""{1}""> // | |
//Copyright (c) {1}. All rights reserved. // | |
//<author> The king of Dons </author> // <date>{2}</date> // </copyright> | |
//-----------------------------------------------------------------------`r`n" | |
function Write-Header ($file) | |
{ | |
$content = Get-Content $file | |
$filename = Split-Path -Leaf $file | |
$fileheader = $header -f $filename,$companyname,$date | |
Set-Content $file $fileheader | |
Add-Content $file $content } | |
Get-ChildItem $target -Recurse | ? { $_.Extension -like ".cs" } | % ` | |
{ | |
Write-Header $_.PSPath.Split(":", 3)[2] | |
} |