david_williams | 2aec693 | 2009-05-28 16:34:57 +0000 | [diff] [blame] | 1 | #!/bin/sh |
| 2 | |
| 3 | # Important: it is assumed this script is ran from the directory |
| 4 | # that is the parent of the directory to rename |
| 5 | |
| 6 | oldname=$1 |
| 7 | newname=$2 |
| 8 | |
| 9 | function renamefile () |
| 10 | { |
| 11 | # file name is input parameter |
| 12 | if [[ $1 =~ "(.*)($oldname)(.*)" ]] |
| 13 | then |
| 14 | echo "changing $1 to ${BASH_REMATCH[1]}$newname${BASH_REMATCH[3]}" |
| 15 | mv "$1" "${BASH_REMATCH[1]}$newname${BASH_REMATCH[3]}" |
| 16 | |
| 17 | fi |
| 18 | |
| 19 | } |
| 20 | |
| 21 | |
| 22 | echo "Renaming build $oldname to $newname" |
| 23 | |
| 24 | fromString=$oldname |
| 25 | toString=$newname |
| 26 | replaceCommand="s!${fromString}!${toString}!g" |
| 27 | |
| 28 | perl -w -pi -e ${replaceCommand} ${oldname}/*.php |
| 29 | perl -w -pi -e ${replaceCommand} ${oldname}/*.map |
| 30 | perl -w -pi -e ${replaceCommand} ${oldname}/*.html |
| 31 | perl -w -pi -e ${replaceCommand} ${oldname}/*.xml |
| 32 | perl -w -pi -e ${replaceCommand} ${oldname}/checksum/* |
| 33 | |
| 34 | # move directory before file renames, so it won't be in file path name twice |
| 35 | mv $oldname $newname |
| 36 | |
| 37 | for file in `find ./${newname} -name "*${oldname}*" -print ` |
| 38 | do |
| 39 | renamefile $file |
| 40 | done |