Created
December 9, 2013 08:36
-
-
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
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:\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