blob: 32cb4b1b3f1579df5ffae7e6213c6a7dbb4af770 [file] [log] [blame]
david_williams51256372010-04-20 21:04:25 +00001#!/usr/bin/env bash
david_williams2aec6932009-05-28 16:34:57 +00002
3# Important: it is assumed this script is ran from the directory
4# that is the parent of the directory to rename
5
6oldname=$1
7newname=$2
8
9function renamefile ()
10{
11# file name is input parameter
david_williamsa3b65602010-08-01 17:50:32 +000012if [[ $1 =~ (.*)($oldname)(.*) ]]
david_williams2aec6932009-05-28 16:34:57 +000013then
14 echo "changing $1 to ${BASH_REMATCH[1]}$newname${BASH_REMATCH[3]}"
15 mv "$1" "${BASH_REMATCH[1]}$newname${BASH_REMATCH[3]}"
16
17fi
18
19}
20
21
22echo "Renaming build $oldname to $newname"
23
24fromString=$oldname
25toString=$newname
26replaceCommand="s!${fromString}!${toString}!g"
27
david_williams5c51ca42011-09-17 20:30:09 +000028# not all these file types may exist, we include all the commonly used ones, though,
29# just in case future changes to site files started to have them. There is no harm, per se,
30# if the perl command fails.
31# TODO: could add some "smarts" here to see if all was as expected before making changes.
david_williams2aec6932009-05-28 16:34:57 +000032perl -w -pi -e ${replaceCommand} ${oldname}/*.php
33perl -w -pi -e ${replaceCommand} ${oldname}/*.map
34perl -w -pi -e ${replaceCommand} ${oldname}/*.html
35perl -w -pi -e ${replaceCommand} ${oldname}/*.xml
36perl -w -pi -e ${replaceCommand} ${oldname}/checksum/*
37
38# move directory before file renames, so it won't be in file path name twice
39mv $oldname $newname
40
41for file in `find ./${newname} -name "*${oldname}*" -print `
42do
43 renamefile $file
44done