Skip to content

Instantly share code, notes, and snippets.

@bojidar-bg
Last active November 2, 2016 14:37
Show Gist options
  • Save bojidar-bg/efab99c356c531db95f2d02a0d387e06 to your computer and use it in GitHub Desktop.
Save bojidar-bg/efab99c356c531db95f2d02a0d387e06 to your computer and use it in GitHub Desktop.
GPFAMR - Godot "Project" Fixers After Mass Rename (move)
#!/usr/bin/env bash
v=$(echo "$@" | grep -- '-v')
d=$(echo "$@" | grep -- '-d')
sed_command=''
# Doesn't support spaces in names :|
for cf in $(find . -not -path '*.git*' -not -name '* *' -type f | sed 's|\./||g'); do
if [ ! -z "$v" ]; then
echo "Adding $(basename $cf) -> $cf.."
fi
sed_command='s|"([^"]+)//([^"]+/)?'$(basename $cf)'"|"\1//'$cf'"|g;'$sed_command
done
if [ -z "$d" ]; then
echo "Running real replacement.."
# Doesn't support spaces in names :|
for rf in $(find . -not -path '*.git*' -type f -not -name '*.png' -not -name '*.jpg' -not -name '*.gif' -not -name '* *' ); do
sed -i -E -e "$sed_command" "$rf" > /dev/null
if [ ! -z "$v" ]; then
echo "Replaced in $rf.."
fi
done
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment