Skip to content

Instantly share code, notes, and snippets.

@BorisKozo
Created December 9, 2013 08:36
Show Gist options
  • Save BorisKozo/7869144 to your computer and use it in GitHub Desktop.
Save BorisKozo/7869144 to your computer and use it in GitHub Desktop.
A PowerShell script by Leniel Macaferi to add a header to all .cs files in a directory
param($target = "C:\MyProject", $companyname = "My Company", $date = (Get-Date))
$header = "//-----------------------------------------------------------------------
// <copyright file=""{0}"" company=""{1}"">
// Copyright (c) {1}. All rights reserved.
// <author>Leniel Macaferi</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]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment