Okay, this is just a start -- I haven't made it recursive yet -- but just in case I get this bee in my bonnet again, I want to remember what I'd done to this point.

Got a library that needs licensing? You'll want to change the save location from C:\temp\out\ (later I'll make that a param I guess). You might also change what's in $license from the MPL (though it is my favorite), but, past that, throw into a Powershell file and you're on your way.

$fileNames = new-object collections.arraylist

$license = @"
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at https://mozilla.org/MPL/2.0/.


"@

Get-ChildItem C:\temp\*.js | %{
    $name = $_.Name
    #Write-Host $name

    $content = new-object collections.arraylist

 
    Get-Content $_.fullname | %{
        $ignore = $content.add($_)
    }

    $newPath = ("C:\temp\out\" + $name)
    write-host $newPath

    $content = $($content -join [Environment]::NewLine)
    ($license + $content) | set-content $newPath
}

Write-Host $($fileNames -join [Environment]::NewLine)

Labels: , ,