Daniel Fetchinson wrote:
>> Will there be a problem if I change the name of a project 'foo'
>> created by tg-admin quickstart by only manually going through and
>> replacing all cases where 'foo' exists with 'matrix' if 'matrix' is
>> the new name of the project I want?
> 
> find . -name "*" | while read f ; do sed s/foo/matrix/g < $f > /tmp/x
> ; mv /tmp/x $f ; done

Please see the attachment for my contribution on this issue. (+file-renaming and
SVN ops)

-- W-Mark Kubacki
#!/bin/bash
# This script will rename a given TurboGears project
#       from $1
#       to   $2
# Given $1 ist the name in CamelCase.
#
# author: W-Mark Kubacki; [EMAIL PROTECTED]

# first of all, rename files
function mv_files {
        FILES=($(find -name "*$1*" ! -name '*.svn*'))
        for FN in [EMAIL PROTECTED]; do
                svn mv "${FN}" "${FN/$1/$2}"
        done
}

# then, replace every occurence inside the file
function repl_occurence {
        FILES=($(grep -rl "$1" ./* | grep -v '.svn'))
        for FN in [EMAIL PROTECTED]; do
                sed "s/$1/$2/g" "${FN}" > "${FN}.new" \
                && mv "${FN}.new" "${FN}"
        done
}

if [ "$1" -a "$2" ]; then
        OLD_CC="$1"
        NEW_CC="$2"
        OLD_LW=$(echo -n "${OLD_CC}" | tr '[:upper:]' '[:lower:]')
        NEW_LW=$(echo -n "${NEW_CC}" | tr '[:upper:]' '[:lower:]')

        mv_files "${OLD_CC}" "${NEW_CC}"
        mv_files "${OLD_LW}" "${NEW_LW}"
        repl_occurence "${OLD_CC}" "${NEW_CC}"
        repl_occurence "${OLD_LW}" "${NEW_LW}"
else
        echo "Usage: $0 'OldName' 'NewName'"
fi

Attachment: smime.p7s
Description: S/MIME Cryptographic Signature

Reply via email to