#!/bin/sh
#
# cvs rename directories
#
# written by Markus Neteler 3/2000
# $Id: cvs.rename.dir,v 1.3 2002/02/13 12:46:49 markus Exp $

if [ $# -lt 2 -o "$1" = "" -o "$1" = "help" -o "$1" = "-h" -o "$1" = "-help" ]
    then
     echo "USAGE: cvs.rename old_directory_name  new_directory_name"
     echo ""
     echo "use command in parent directory and specify old and new name." 
    else
      olddir=$1
      newdir=$2
fi
if [ ! "$newdir" ]
then
   exit
fi

# here we go...
if [ ! -d $newdir ]; then mkdir $newdir ; fi
cvs add $newdir

cd $olddir
files=`find . -type f -maxdepth 1`
for i in $files ; do
 mv $i ../$newdir
done
cvs rm *

cd ../$newdir
cvs add *
cd ..
cvs remove -R $olddir
# work on all dirs:
cvs ci -m "moved $olddir/ to $newdir/: renamed directory"
cvs update -P

echo "Finish."
