#! /bin/sh
#
# Copyright (C) 2003, 2005-2007 Free Software Foundation, Inc.
#
# This program is free software; you can redistribute it and/or modify it
# under the terms of the GNU Library General Public License as published
# by the Free Software Foundation; either version 2, or (at your option)
# any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU Library General Public
# License along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
# USA.
#

  case "$0" in
    series2epatch | */series2epatch | *\\series2epatch)
      progname=$0
      package=series2epatch
      version=@VERSION@
      # func_usage
      # outputs to stdout the --help usage message.
      func_usage ()
      {
        echo "series2epatch shell script version $version"
        echo "Usage: . series2epatch <start number> <source dir> <destination dir>"
      }
      # func_version
      # outputs to stdout the --version message.
      func_version ()
      {
        echo "$progname (GNU $package) $version"
        echo "Copyright (C) 2003-2007 Free Software Foundation, Inc.
License GPLv2+: GNU GPL version 2 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law."
        echo "Written by" "Mario Fetka"
      }
      if test $# = 1; then
        case "$1" in
          --help | --hel | --he | --h )
            func_usage; exit 0 ;;
          --version | --versio | --versi | --vers | --ver | --ve | --v )
            func_version; exit 0 ;;
        esac
      fi
      func_usage 1>&2
      exit 1
      ;;
  esac

sed -e '/^#/d' -i $2/series

cnt=$1
for f in $(<$2/series) ; do
        cp $2/${f} $3/${cnt}_${f##*/}
        ((cnt++))
done