Linux/mac script for renaming a unit in game code
Posted: 13 Sep 2012, 00:02
I put together this shell script (runs on Linux and Mac) that will go through all your game files and attempt to rename a unit. It will rename all appropriate files and go through all your files and replace all instances of the old unit name with the new name.
save this program as "renameUnit.sh" and place it inside your mod's folder.
run it like:
Code: Select all
Disclaimer - this works for me, but YMMV. Back up your data before trying this.
Code: Select all
for file in `find . -name "*.lua"`
do
sed -i "s/$1/$2/g" $file
done
for file in `find . -name "*.s3o"`
do
sed -i "s/$1/$2/g" $file
done
for infile in `find . \( ! -regex '.*/\..*' \)`
do
newname=`echo $infile | sed "s/$1/$2/"`
if [ "$infile" != "$newname" ]
then
mv $infile $newname
#### ^^^ important! ^^^
#if you use a version-control system like SVN or Git,
# change that line to from "mv" to "git mv",
# "svn mv", or whatever your VCS requires.
####
fi
done
Code: Select all
./renameUnit.sh oldunitname newunitname