- Get list of files required
find . -type f -name '*ghost*.js'
rm -rf ~/temp/scaffolder
mkdir -p ~/temp/scaffolder
Copy all .js
files and replace ghost
with unicorn
IMPORTANT:
On OSX ... replace sed
with gsed
(Credit: https://stackoverflow.com/questions/17534840/sed-throws-bad-flag-in-substitute-command)
bash
rm -rf scaffolder
tree scaffolder
mkdir -p scaffolder
find . -type f -name '*ghost*.js' | while IFS= read -r f; do
echo $f
f=${f//.\//};
echo $f
echo $(dirname "scaffolder/$f")
dirPath=$(dirname "scaffolder/$f")
echo $dirPath
fname=`basename $f`
echo $fname
echo ${fname//ghost/unicorn}
newName=${fname//ghost/unicorn}
echo $newName
mkdir -p $(dirname "scaffolder/$f")
cp $f $dirPath/$newName
sed -i 's/ghost/unicorn/g' $dirPath/$newName
sed -i 's/Ghost/Unicorn/g' $dirPath/$newName
done
tree scaffolder
Copy all .html
files and replace ghost
with unicorn
tree scaffolder
mkdir -p scaffolder
find . -type f -name '*ghost*.html' | while IFS= read -r f; do
echo $f
f=${f//.\//};
echo $f
echo $(dirname "scaffolder/$f")
dirPath=$(dirname "scaffolder/$f")
echo $dirPath
fname=`basename $f`
echo $fname
echo ${fname//ghost/unicorn}
newName=${fname//ghost/unicorn}
echo $newName
mkdir -p $(dirname "scaffolder/$f")
cp $f $dirPath/$newName
sed -i 's/ghost/unicorn/g' $dirPath/$newName
sed -i 's/Ghost/Unicorn/g' $dirPath/$newName
done
tree scaffolder
rsync -av scaffolder/* .
rm -rf scaffolder/
That's it! Da shit rocks!