Last active
November 2, 2016 14:37
-
-
Save bojidar-bg/efab99c356c531db95f2d02a0d387e06 to your computer and use it in GitHub Desktop.
GPFAMR - Godot "Project" Fixers After Mass Rename (move)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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