Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@kavun
Last active April 17, 2018 15:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kavun/2a3704bfb31b84aaa3399ad11c78ea3b to your computer and use it in GitHub Desktop.
Save kavun/2a3704bfb31b84aaa3399ad11c78ea3b to your computer and use it in GitHub Desktop.
if [[ -d $1 ]]; then
if [[ -d $1/.git ]]; then
cd $1
dirn=${PWD##*/};
today=`date '+%Y%m%d%H%M%S'`;
filen='./../'$dirn'_BeforeCaseChange_'$today'.zip';
echo 'Backing up '$dirn' to '$filen
zip -rq $filen .
oldignorecase=$(git config --global --get core.ignorecase)
echo 'Setting "git config --global core.ignorecase false" from core.ignorecase='$oldignorecase
git config --global core.ignorecase false;
echo 'Making all files and folders lowercase';
for f in `find *`; do
git mv -v "$f" "`echo $f | tr '[A-Z]' '[a-z]'`" > /dev/null 2>&1;
done;
echo 'Success!';
echo '';
echo 'Files and folders in '$dirn' have been made lowercase. Now you should stage all files, commit, and push to buddy.'
else
echo "$1 does not contain a .git folder"
exit 1
fi
elif [[ -f $1 ]]; then
echo "$1 is a file, please provide a directory"
else
echo "$1 is not a valid folder"
exit 1
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment