fuel-web/rename.sh
Vladimir Kozhukalov 803272467e Added rename.sh
2013-03-27 09:48:31 +00:00

29 lines
636 B
Bash
Executable File

#!/bin/bash
usage(){
echo "Usage: `basename $0` <project_root_dir> <old_string> <new_string>"
exit 1
}
if [ $# -ne 3 ]; then
usage
fi
(
cd $1
old=$2
new=$3
grep -r $old * 2>/dev/null | awk -F: '{print $1}' | sort | uniq | while read file; do
echo "sed -i -e \"s/${old}/${new}/g\" $file"
sed -i -e "s/${old}/${new}/g" $file
done
find -name "*${old}*" | sort -r | while read oldfile; do
d=`dirname $oldfile`
f=`basename $oldfile`
newfile=${d}/`echo $f | sed -e "s/${old}/${new}/g"`
echo "mv $oldfile $newfile"
mv $oldfile $newfile
done
)