#!/bin/bash

perl -0777 -p -i -e '
s!(([#%]*) *)License\n.*?\n[#%]*\n.*?\n[#%]*\n.*?\n[#%]*\n.*?\n[#%]*\n!$1License
$1    This file is part of foam-extend.
$2
$1    foam-extend is free software: you can redistribute it and/or modify it
$1    under the terms of the GNU General Public License as published by the
$1    Free Software Foundation, either version 3 of the License, or (at your
$1    option) any later version.
$2
$1    foam-extend is distributed in the hope that it will be useful, but
$1    WITHOUT ANY WARRANTY; without even the implied warranty of
$1    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
$1    General Public License for more details.
$2
$1    You should have received a copy of the GNU General Public License
$1    along with foam-extend.  If not, see <http://www.gnu.org/licenses/>.
$2
!s;
s!OpenFOAM: The Open Source CFD Toolbox$!foam-extend: Open Source CFD!m;
s!\| Copyright(.*?)\n!| For copyright notice see file Copyright\n!s;
s!\| OpenFOAM: The Open Source CFD Toolbox           \|!| foam-extend: Open Source CFD                    |!;
s!\| OpenFOAM Extend Project: Open [sS]ource CFD        \|!| foam-extend: Open Source CFD                    |!;
s!\| Version:  [1-9].[0-9][. -][ex ][x ][t ]                               \|!| Version:     3.1                                |!;
s!\| Version:     3.0                                \|!| Version:     3.1                                |!;
s!\| Web:      http://www.OpenFOAM.org               \|!| Web:         http://www.extend-project.de       |!;
s!\| Web:      www.OpenFOAM.org                      \|!| Web:         http://www.extend-project.de       |!;
s!\| Web:      www.extend-project.de                 \|!| Web:         http://www.extend-project.de       |!;
s!\| \\\\      /  F ield         \| foam-extend Project: Open source CFD        \|!| \\\\      /  F ield         | foam-extend: Open Source CFD                    |!;
s!\|  \\\\    /   O peration     \| Version:  3.0                               \|!|  \\\\    /   O peration     | Version:     3.1                                |!;
s!README file for version 3.0\*!README file for version 3.1*!;
' $1

