#!/bin/bash function help_exit(){ echo "usage: bash $0 " echo "Do not pass path names as arguments!!" echo -e '\033[0;31m' "Exiting the script with failure!!" '\033[0m' exit 1 } if [ "$#" -ne 2 ] || [ "$2" == "" ]; then help_exit fi if [[ ! -d "${1}" ]]; then echo -e '\033[0;31m' "[ERROR] There is no project with the name $1 " '\033[0m' help_exit exit 1 fi if [ -d "${2}" ]; then echo -e '\033[0;31m' "[ERROR] A project already exists with the name $2, try with a different name for target project" '\033[0m' help_exit exit 1 fi OPWD=$(pwd) OLD=$1 NEW=$2 echo "Copy component $OLD to $NEW? [y/n]" read answer if [ "$answer" != "y" ]; then echo "aborting" exit 1 fi cp -r $OLD $NEW cd $NEW rm -rf bin/ smartsoft/build/ for I in $(find -name "*$OLD*"); do mv $I $(echo $I| sed "s/$OLD/$NEW/g"); done for I in $(grep -Rl $OLD * .cproject .project); do sed -i "s/$OLD/$NEW/g" $I; done cd $OPWD